IE7中的window.location.hash问题 [英] window.location.hash issue in IE7

查看:117
本文介绍了IE7中的window.location.hash问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个javascript函数,应该使用锚点将页面移动到某个位置。这个函数只是 window.location.href =#+ hashName 。这适用于FF,但不适用于IE。我在Windows XP下使用IE7测试了这段代码。
我尝试使用window.location.href window.location.hash window.location.replace 以及所有这些方法,但使用 document object。
有谁知道如何处理这个问题?

We have a javascript function that should "move" a page to a certain position using anchors. This function just does window.location.href = "#" + hashName. This works in FF, but not in IE. I tested this code using IE7 under Windows XP. I have tried using window.location.href, window.location.hash, window.location.replace and all these ways, but using document object. Does anyone know how to deal with this issue?

推荐答案

IE和大多数其他浏览器将滚动到一个锚点anchor.focus(),或任何id为element.scrollIntoView(true)的元素

IE and most other browsers will scroll to an anchor with anchor.focus(), or to any element with an id with element.scrollIntoView(true)

这篇关于IE7中的window.location.hash问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆