Q_24598697: Click to open new part of page and scroll to it
This example show how you can click on a link that links to an anchor
and at the same time make that part of the document visible. This is handy
for one-view pages where the initial page is not scrollable.
This page will remain online for future reference. The original question
can be viewed at Experts-Exchange, but requires (free) membership.
More information about me, about how this site is maintained and about
how to use these pages for yourself, check out the opening page.
click to see this demo
Use the following code:
Call the two functions in the onclick of a a-href and set the #name to the same
name as the id. This will both scroll to the block and make it visible.
<script type="text/javascript>
function openBlock(id){
var obj = document.getElementById(id);
obj.style.display = "block";
return true;
}
function closeBlock(id) {
var obj = document.getElementById(id);
obj.style.display = "none";
return true;
}
</script>
<-- example href as used below -->
<a href="#readfurther" onclick="openBlock('readfurther')">Read further>/a>
Further reading here in the green block, which is just a normal
paragraph block (inside a wrapping div) which is made visible for
you when clicking on "read further". You can
close this block to
go back to the top.
The following text is courtesy to Lorum Ipsum,
I used it to make this block substantial in size
What is Lorum Ipsum
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
Where does it come from
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.
The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
Why do we use it?
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
Here's some block of it:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur a nisi vel lectus facilisis tristique. Mauris vulputate, nunc sed viverra interdum, nisl est fringilla magna, a ornare enim est eget metus. Ut aliquet, tellus sed fringilla pulvinar, tellus velit consequat velit, ac rutrum massa dolor sit amet arcu. Curabitur ac nulla vel nibh bibendum facilisis eget vel sem. Nulla a nulla non lectus commodo condimentum nec vel lacus. Ut eu odio quis augue fringilla eleifend. Donec ac orci a lectus tincidunt lacinia ac eu diam. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Duis gravida tortor vel risus malesuada interdum. In ultrices sapien id ligula imperdiet vel molestie diam bibendum. Quisque felis nisl, scelerisque malesuada eleifend non, auctor ullamcorper augue. Quisque mattis nibh non urna pulvinar sollicitudin. Etiam ut sem eget libero pulvinar ultricies. Nam vestibulum accumsan quam, vitae hendrerit leo suscipit sed. Suspendisse libero elit, faucibus et blandit sed, gravida eu ipsum.
Proin dignissim lectus quis est vehicula eu bibendum nibh aliquam. Maecenas eleifend leo in metus fringilla a consectetur nunc ultrices. Phasellus luctus tempor erat, eget ultrices nulla placerat nec. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. In vitae metus erat, placerat aliquet dui. Mauris ut risus eu erat tincidunt sagittis vitae at libero. Sed sed vestibulum odio. Aliquam pellentesque facilisis eleifend. Etiam dictum egestas magna sed euismod. Cras sodales felis id ligula scelerisque lobortis. Maecenas ullamcorper rhoncus dui, ut mollis erat egestas non.
Mauris posuere ipsum vel est accumsan pretium. Vivamus elementum congue diam, nec euismod justo pharetra et. Donec vestibulum ultricies turpis, sed fermentum risus mollis in. Suspendisse eget nibh at sem facilisis rhoncus varius non felis. Nunc hendrerit nulla vel eros gravida porttitor. Nunc elit arcu, iaculis sit amet vulputate in, ultrices id risus. Nunc a nibh et nibh sollicitudin hendrerit at ac metus. Cras ac libero dui. Fusce pulvinar elit dignissim justo vulputate ultrices. Quisque pulvinar ornare hendrerit. Ut cursus lorem at magna luctus tempus vestibulum purus egestas. Integer dictum tincidunt est ut dignissim. Mauris tempor euismod erat, nec fringilla libero lacinia ac. Pellentesque et ante quam, id imperdiet lacus. Pellentesque posuere molestie egestas. Fusce vulputate eros eu magna vestibulum sollicitudin. Fusce vulputate neque vitae erat lobortis posuere. In vitae purus non turpis porttitor rutrum quis ac quam.
Sed faucibus, ligula sed porta vulputate, enim felis aliquam ante, dapibus egestas justo turpis id eros. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nulla rutrum lectus eu mauris mattis nec condimentum lectus malesuada. Praesent arcu eros, consectetur et auctor vel, tristique non est. Aliquam sed sem vel odio aliquet tristique sed elementum libero. Aenean pretium urna nec nisi congue quis fringilla elit laoreet. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Mauris pellentesque, urna vel feugiat auctor, dolor metus vulputate turpis, eu porttitor arcu sapien eu mi. Sed faucibus porttitor pulvinar. Maecenas semper quam nec nunc aliquam feugiat. Aenean eget aliquet risus. Etiam pulvinar, lectus eu placerat facilisis, sapien ligula consectetur sem, ut porta velit urna eu ligula. Vestibulum gravida metus nec arcu aliquam bibendum. Suspendisse eget odio libero. In hac habitasse platea dictumst. Morbi justo turpis, pharetra ac mattis pharetra, ultrices at erat.
Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Maecenas varius consectetur semper. Nulla in nisl ante. Maecenas massa dolor, pretium tincidunt egestas eget, porta a ipsum. Donec a purus purus. Sed tortor nisi, egestas vitae tristique a, luctus ac leo. Fusce quis augue et turpis commodo iaculis. Nam tincidunt tincidunt tincidunt. Nam at leo ac purus egestas eleifend vitae non elit. Nam pulvinar, orci at feugiat placerat, nibh nibh rutrum urna, a laoreet leo orci in justo. Nulla facilisi.