I want to execute the following script
$('html, body').animate({
scrollTop: $('#deckblatt').offset().top
}, 1)
deckblatt is the first content-div on my page.
Chrome won’t do this, but FF would.
The confusing part is that i’ve got the same excent method running on a second page, which works perfectly fine on both Chrome and FF.
What have i missed or is there maybe a better way to do what i want to achieve, preventing the browser from automatically jumping to a section of the page when it was scrolled down before?
Thank you in advance.
EDIT:
Here is the complete code for the first project, which is not running correctly
And here is the code of the second one, which works fine
It’s not a Chrome bug. Your original code contains some strange stuffs.
scroll-topclass, which should be shown when scrolling down, and which the user could click on to scroll to the top.toporbottomid like in the other one.But one of the most important errors:
targetvariable is undefined in your JavaScript code, and you inspect its equality with “#top” string. This leads to a ReferenceError exception. I think you wanted to inspect whether the click event’s target element’s id is equal to the"#top"string. For this, you should declare e.g. theeventargument in the event handler, and useevent.target.id.So instead of this:
You should use this code:
I modified your original code, uncommenting very much unneeded stuffs, but there are still many left:
http://jsfiddle.net/uKcQG/3/
It’s still a little buggy, but now the scrolling seems to work correctly.
But as I suggested in my comment, you should definitely use Ariel Flesler’s jQuery scrollTo plugin for this task: http://demos.flesler.com/jquery/scrollTo/