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>
function ScrollToElement(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
<a name="d1" />
<div id="d1">
<a name="d2" />
<div id="d2">
<a name="d3" />
<div id="d3">
<a name="d4" />
<div id="d4">
<a name="d5" />
<div id="d5">
<a name="d6" />
<div id="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)?"