开发者

window.location.href does not work in IE8

I have to scroll up in a page. Therefore I put a an anchor at the corr开发者_如何转开发ect place and then I did

window.location.href = 'http://example.org/#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 :)


For IE 8 just use it like this, it will work:

window.location = 'http://example.org/#anchor';

Hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜