admin管理员组文章数量:1356898
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.
本文标签: javascriptwindowlocationhref does not work in IE8Stack Overflow
版权声明:本文标题:javascript - window.location.href does not work in IE8 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744035255a2579653.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论