window.location does not work on Firefox
I had a scenario wherein a user clicks a button and a client side javascript function executes and redirects user to another page.
I used window.location.href for redirection, but this did not work in firefox. Having looked up at other sites, the suggestion was to use window.location but this did not work still.
I then realised that the problem was the way the javascript function was called in the onclick event of the button and it required a return false; to get it working.
Below is the code sample, the button has a return false, which prevents the form from submitting to itself and enable re-direction.
<script language="javascript" type="text/javascript">
function GoToRegistration() {
var url = "http://www.lotussoftwaremall.com/"
window.location=url;
}
</script>
<input name="submit" type="image" src="submitbutton.png" onclick="GoToRegistration();return false;" width="80" height="29" />
I used window.location.href for redirection, but this did not work in firefox. Having looked up at other sites, the suggestion was to use window.location but this did not work still.
I then realised that the problem was the way the javascript function was called in the onclick event of the button and it required a return false; to get it working.
Below is the code sample, the button has a return false, which prevents the form from submitting to itself and enable re-direction.
<script language="javascript" type="text/javascript">
function GoToRegistration() {
var url = "http://www.lotussoftwaremall.com/"
window.location=url;
}
</script>
<input name="submit" type="image" src="submitbutton.png" onclick="GoToRegistration();return false;" width="80" height="29" />
Comments