Dewsworld
Dewsworld

Reputation: 14033

jQuery .unload() doesn't show anything

I have the following code:

<html>
<head>
    <title>D</title>
    <script type="text/javascript" src="jQuery.js">
    <script type="text/javascript">
    $(window).unload( function () { alert("Bye now!"); } );
    </script>    
</head>

<body>
     <span>Hello world</span>
</body>
</html>

But this doesn't show anything.

[Edit] There are two things:

  1. I had a dummy mistake, not ending with < / script> tag. Now, it's working on FF.
  2. But not chrome, as genesis told, it's a bug!

Upvotes: 2

Views: 1650

Answers (2)

ALEX ORTIZ
ALEX ORTIZ

Reputation: 189

use

<script>window.onbeforeunload = function(){ return 'Your Returned String Goes Here';}/script>

Upvotes: 0

genesis
genesis

Reputation: 50976

jQuery's .unload() event doesn't work in Google Chrome 14 and above. This is new reported bug. (13 days old)

That is probably just a security measure from Google's side

Upvotes: 4

Related Questions