javascript - window.location.href 在 IE8 中不起作用

标签 javascript internet-explorer-8

我必须在页面中向上滚动。因此我在正确的位置放置了一个 anchor ,然后我就这样做了

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

这适用于 FF、Chrome、Safari 和 IE9。但在 IE8 中什么也没有发生(它不滚动)。

我也尝试过:

window.location.hash = "anchor";
window.location.hash = "#anchor";
scrollTo(0, 0);

但是,IE8就是不想滚动。将焦点转移到 anchor 上很重要。无法重新加载。

提前感谢您的任何提示:)

最佳答案

对于 IE 8 只需像这样使用它,它就会工作:

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

希望这有帮助。

关于javascript - window.location.href 在 IE8 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7753909/

相关文章:

javascript - 无法在 Angular 7 中的 SVG 上触发鼠标事件

javascript - 这个 Backbone todo 应用程序如何将所有元素呈现到页面上?

javascript - React-data-grid 无法实现行分组 - 也可能存在插件问题

jQuery XML 解析 IE7/IE8

Javascript:向表单输入数据时,提交按钮未激活

javascript - AngularJS 刷新时漂亮的 URL 路由

html - CSS table nth child() last td 不显示边框

visual-studio-2008 - 在 Release模式下 Internet Explorer 8 崩溃后,我需要调试我的 BrowserHelperObject (BHO)(在 C++ 中使用 Visual Studio 2008)

jquery 1.6.2 和 IE8 错误

javascript - 如何在 IE8 中禁用 ondblclick?