Jump to content

Why not working in IE or on MAC (FF or Safari)?


n1concepts
Go to solution Solved by n1concepts,

Recommended Posts

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>
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • Solution

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 by n1concepts
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.