redirect - JavaScript window.location.replace works in Firefox but not IE or Chrome -


the following script works marvelously in firefox has no success @ in ie or chrome....i've been pounding head hours on stupidity....any appreciated.

<script type="text/javascript">  window.onunload = function exitconfirm()  {     var answer = confirm("wait don't go! love you!");     if (answer)        {           if(!self.closed)           {              window.open("http://mykoolurl");           }else{              window.location.replace("http://mykoolurl");           }        }  } </script> 

the confirm works fine both page leave , broswer/page/tab close no matter selection choice in ie/chrome no redirect taking place. me understand.

update more simple example using onbeforeunload:

<body onbeforeunload=go();> function go() {    if(confirm("go google"))    {      window.location.href = "http://www.google.com";    } } </body> 

this not work in ie/chrome/safari have used few different machines try eliminate setting errors of kind. insane situation missing obvious...??? why redirect not doing in these browsers...is me? i've tried cute js redirects:

location location.href location.reload location.open etc 

even jquery

$(location).attr('href','http://www.google.com'); 

again these work fine on machine in fire fox

you can also

window.location.href = 'http://mykoolurl'; 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -