I have to scroll up in a page. Therefore I put a an anchor at the correct place and then I did
window.location.href = '';
This works fine with FF, Chrome, Safari and IE9. But in IE8 nothing happens (it does not scroll).
I also tried:
window.location.hash = "anchor";
window.location.hash = "#anchor";
scrollTo(0, 0);
However, IE8 just does not want to scroll. It is important that we move the focus to the anchor. A reloading is not possible.
Thanks in advance for any tipps :)
I have to scroll up in a page. Therefore I put a an anchor at the correct place and then I did
window.location.href = 'http://example/#anchor';
This works fine with FF, Chrome, Safari and IE9. But in IE8 nothing happens (it does not scroll).
I also tried:
window.location.hash = "anchor";
window.location.hash = "#anchor";
scrollTo(0, 0);
However, IE8 just does not want to scroll. It is important that we move the focus to the anchor. A reloading is not possible.
Thanks in advance for any tipps :)
Share Improve this question asked Oct 13, 2011 at 12:10 mknmkn 13.2k17 gold badges52 silver badges64 bronze badges 3- 1 Have you tried the ".scrollIntoView()" method on the element? – Pointy Commented Oct 13, 2011 at 12:12
- @Pointy then I would have to get the anchor element first right? I tried a similar solution with a <div id="anchor"> and then get that element and call scrollIntoView on it. It does not work :( – mkn Commented Oct 13, 2011 at 12:38
- I've used "scrollIntoView" in IE many times and it has always worked fine for me. Maybe if you could prepare a jsfiddle people could help investigate. – Pointy Commented Oct 13, 2011 at 13:39
1 Answer
Reset to default 7For IE 8 just use it like this, it will work:
window.location = 'http://example/#anchor';
Hope this helps.