windows.location.href not working on Firefox3
Solution 1:
Have you tried just using
window.location = 'url';
In some browsers, window.location.href
is 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 the location
property 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.location
object.
https://developer.mozilla.org/en/DOM/window.location
Solution 2:
If you are trying to call this javascript code after an event that is followed by a callback then you must add another line to your function:
function JSNavSomewhere()
{
window.location.href = myUrl;
return false;
}
in your markup for the page, the control that calls this function on click must return this function's value
<asp:button ........ onclick="return JSNavSomewhere();" />
The false return value will cancel the callback and the redirection will now work. Why this works in IE? Well I guess they were thinking differently on the issue when they prioritized the redirection over the callback.
Hope this helps!
Solution 3:
One observation to ensure in such a scenario
Following will work in IE
, but neither in Chrome
nor in Firefox
(the versions I tested)
window.location.href("http://stackoverflow.com");
Following will work all the three
window.location.href = "http://stackoverflow.com";
Solution 4:
Maybe it's just a typo in your post and not in your code, but it's window and not windows