Curious redirection problem using location.href
Posted
by Jose M Balaguer
on Stack Overflow
See other posts from Stack Overflow
or by Jose M Balaguer
Published on 2010-04-25T13:16:10Z
Indexed on
2010/04/25
13:23 UTC
Read the original article
Hit count: 341
I face a curious problem with redirection...
Look at this small example: it works only if I add the alert() call after the redirection sentence! If I remove the alert() it does not work anymore!!!
Any idea why (I'm using Firefox 3)?
Thanks.
<html>
<script type="text/javascript">
function GotoPage() {
location.href = "http://www.yahoo.com";
// Without this alert redirection does not work!!!
alert("Hello!");
}
</script>
<body>
<form>
<button onclick="javascript:GotoPage()">Go</button>
</form>
</body>
</html>
© Stack Overflow or respective owner