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?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- How to fix IE ClearType + jQuery opacity problem i
- void before promise syntax
- Keeping track of variable instances
There is also a problem i came across
http://artur.ejsmont.org/blog/content/window-location-hash-difference-in-ff3-and-opera
IE and most other browsers will scroll to an anchor with anchor.focus(), or to any element with an id with element.scrollIntoView(true)
Have you tried changing just
location.hash
?I justed tested this in IE7 under Vista, maybe the issue only exsists in IE7 under XP? Because this works fine for me in IE7, Chrome and Firefox:
If this really doesn't work then we could use scrollIntoView as Kennebec suggests.
Use like this: