I have an issue with my website. My page loads normally in Firefox, but when I use either Chrome or Safari, it goes to the bottom of the page and I don't understand why. I tried putting the following snippet at the beginning of the page, but no luck.
<script>
$(document).ready(function() {
$(document).scrollTop(0);
});
</script>
Why does the page go to the bottom on loading?
I have an issue with my website. My page loads normally in Firefox, but when I use either Chrome or Safari, it goes to the bottom of the page and I don't understand why. I tried putting the following snippet at the beginning of the page, but no luck.
<script>
$(document).ready(function() {
$(document).scrollTop(0);
});
</script>
Why does the page go to the bottom on loading?
Share Improve this question edited Apr 10, 2013 at 12:50 Darin Kolev 3,40913 gold badges33 silver badges47 bronze badges asked Apr 10, 2013 at 12:24 DikenekoDikeneko 3564 silver badges21 bronze badges 2- 1 Is there something in your page that gets the focus when the page is loaded? Perhaps this element is near the bottom of the page? – Borniet Commented Apr 10, 2013 at 12:26
- It works fine for me with chrome version 26.0.1410.43 m – Sven van den Boogaart Commented Apr 10, 2013 at 12:33
4 Answers
Reset to default 5When going to your site, I get redirected to http://www.ondinevermenot.fr/#start. That means the page will try to jump to the start
element.
However, the start
element is absolutely positioned. Therefore, when the page tries to jump down, the start
element moves down with it. Therefore the page tries to jump down again. Then the start
element moves down more. They keep going down until the bottom of the page, when there is no more room.
To fix it, don't redirect to #start
when your page loads.
Because of the strangeness of jumping to something that's absolutely positioned, it's probably handled differently in different browsers.
Try to have your image and other contents put inside div and set the box attribute of the div to margin:auto. works well with HTML5.
i have an alturnative work around for you and incase you ever need to get to the top of the page - you can use this javascript as an alturnative:
((IJavaScriptExecutor)webapplication).ExecuteScript("window.scrollTo(0, document.body.scrollHeight 0)");
however the other option would be to set a start up property: for example document.start("body.height = 0") something along those lines may work.
preferably id use option one as a code to start the broswer at a set height may not work so well for every browser. hope this helps.
I had 2 links to my home page in my footer. When I removed the links from my footer the problem went away.