How To Have A Page Load To The Middle Of The Page (instead Of Top)?
I'd like for the page to open at a certain div halfway down the page, not at the top... I have something like:
Solution 1:
<script>functionScrollToElement(theElement){
var selectedPosX = 0;
var selectedPosY = 0;
while(theElement != null){
selectedPosX += theElement.offsetLeft;
selectedPosY += theElement.offsetTop;
theElement = theElement.offsetParent;
}
window.scrollTo(selectedPosX,selectedPosY);
}
</script>
http://radio.javaranch.com/pascarello/2005/01/09/1105293729000.html
Solution 2:
Find div position using this and then use the following javascript command:
window.scroll(0, DIV_POS); // horizontal and vertical scroll targets
Solution 3:
EDIT: OOPS! didn't read the Except.... disregard!
Note to self, read the entire question before responding!
End EDIT
You could always use an HTML anchor tag
<aname="d1" /><divid="d1"><aname="d2" /><divid="d2"><aname="d3" /><divid="d3"><aname="d4" /><divid="d4"><aname="d5" /><divid="d5"><aname="d6" /><divid="d6">
When you navigate to the page, you would include the anchor name in the url: pagename.htm#d4
Make sure to close your div tags.
Good luck,
Patrick
Solution 4:
You can use Javascript:
location.replace('#d4');
Post a Comment for "How To Have A Page Load To The Middle Of The Page (instead Of Top)?"