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 so
Have you tried this?
Response.Write("<script type='text/javaScript'> window.location = '#myAnchor'; </script>";);
I have the same problem and I guess this is related to a click event.
I have a function that moves the browser to a specific page. I attach that function to some click events: in a button and in a image. AlsoI execute the function when the user press escape (document onkeypress event).
The results are that in all cases the function is called and executed, but only when there is a click the browser goes to the address I want.
Update I got it working! with a
setTimeout( "location.replace('whatever.html');", 0 );
I don't know why the location.replace wasn't working when the event was a keypress, but with the settimeout it works :)
Update Returning false after the event when you press escape makes the redirection works. If you return true or nothing the browser will not follow
You've got to add return false; after the window.location.href as mentioned above.
function thisWorks()
{
window.location.href = "http://www.google.com";
return false;
}
function thisDoesNotWork()
{
window.location.href = "http://www.google.com";
}
sometime if you're using form to post data, this may happen. if you're using ajax, try to change 'form' to 'div'. this will prevent the default behavior of form and do your ajax code.
window.location.assign("link to next page") should work in both (chrome and firefox) browsers.
window.location.assign("link to next page")