n1concepts Posted July 15, 2014 Share Posted July 15, 2014 Hi, I am testing the below JS code in various browsers and it works just fine on my Windows laptop running Firefox but INOP on IE (same laptop) and also from my Mack which runs Firefox and Safari. I'm on the latest versions of all browsers - can someone advise what would prevent the JS function from opening the new page in those browsers mentioned? Note: I am not blocking JS nor popups - this just a test to see how the function works but now I'm curious as to what's really happening... thx! Here's the code: <!doctype html> <html> <head> <meta charset="utf-8"> <!DOCTYPE html> <html> <head> <script type="text/javascript"> function process() { window.open('http://www.w3schools.com/js/', '_blank'); self.blur(); } </script> </head> <body onUnload="process();"> <p> </p> <p>Close the browser or enter another URL in window and press enter.</p> <p>In doing either of those actions, you should be redirected to http://www.w3schools.com/js</p> </body> </html> </head> <body> </body> </html> Quote Link to comment Share on other sites More sharing options...
fastsol Posted July 15, 2014 Share Posted July 15, 2014 Well I don't think it totally your code that is making this not work. I just tried the W3's example page they have and it doesn't work for me on WIndows 7 w/Firefox 30. The one thing I noticed between your code and theirs though is they don't have a ; after the function call in the unload block. And all examples I find show the name to be onunload not onUnload, not sure if that will make a difference here as I am not super at js. Quote Link to comment Share on other sites More sharing options...
Solution n1concepts Posted July 15, 2014 Author Solution Share Posted July 15, 2014 (edited) Hi, You best me to updating this post with similar findings - I found most recent code for this objective use the 'onbeforeunload' event so i updated: <body onbeforeunload="process()"> Also, I found - at least for me - why some of the browsers were not allowing the function to execute. Issue: within preferences, (per browser) I found "Block Pop-up" was checked; soon as I unchecked that option, the JS worked without issue. Thanks - I think I figured this one out (was interested!) Super? You "Da Master" in my book (appreciate support!) Edited July 15, 2014 by n1concepts Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.