Click to See Complete Forum and Search --> : How to go to a location within a document?


dandaman32
06-01-2005, 11:16 PM
Does anyone know how to scroll to a tag with an ID in JS without reloading the page? Here's what I want to do:

...body text...
jump to:
<a name=mylocation id=mylocation></a>
...rest of file...

-dandaman32

vwphillips
06-02-2005, 01:58 AM
see

http://www.vicsjavascripts.org.uk/PageNavigator/PageNavigator.htm

ck_net_2004
06-02-2005, 03:07 AM
This code will scroll An element into view.

<script type="text/javascript">
function scroll_element(theelement){
if(theelement.scrollIntoView){
theelement.scrollIntoView(true); }
}
</script>

<a href="javascript:scroll_element('document.element1');">scroll to element 1</a>
<br>
<a href="javascript:scroll_element('document.element2');">scroll to element 2</a>
<br>
<div id="element1" name="element1">
some text in element 1
</div>
<br>
<div id="element2" name="element2">
some text in element 2
</div>

dandaman32
06-02-2005, 10:28 PM
Thanks for your help!

-dandaman32