We have a JavaScript function named ‘move’ which does just ‘windows.location.href = any given anchor‘.
This function works on IE, Opera and Safari, but somehow is ignored in Firefox. Researching on Google doesn’t produce a satisfactory answer why it doesn’t work.
Does any JavaScript guru knows about this behavior, and what would be the best practice to jump to an anchor via JavaScript?
We have a JavaScript function named move which does just windows.location.href = any given
Share
Have you tried just using
In some browsers,
window.location.hrefis a read-only property and is not the best way to set the location (even though technically it should allow you to). If you use thelocationproperty on its own, that should redirect for you in all browsers.Mozilla’s documentation has a pretty detailed explanation of how to use the
window.locationobject.https://developer.mozilla.org/en/DOM/window.location