agarwal_achhnera
agarwal_achhnera

Reputation: 2456

onunload does in Chrome

I am opening a new window as below to

var nResult = window.showModalDialog("getSelection.asp?Type=" + inputType, "", "dialogHeight:220px; dialogWidth:400px; resizable=no; help:no; status:no");  

Now on getSelection.asp I have following syntax for body

<BODY onload="RetrieveDialogArguments();document.thisForm.ok.focus();" onunload="ReturnDialogArguments()" >

when I put alert then found that onload event works and call to RetrieveDialogArguments() but onunload event does not work and function ReturnDialogArguments() does not call. That's why in nResult I did not get any value. This call works fine Internet Explorer but not in Google Chrome. Please tell me what is the issue with Google Chrome for this.

Upvotes: 0

Views: 1634

Answers (2)

Albert Xing
Albert Xing

Reputation: 5788

onunload is simply not supported in Chrome or Opera. There's nothing you can do about that.

Use onbeforeunload instead, as in:

window.onbeforeunload = function () { // stuff here }

Upvotes: 3

Chirag Bhatia - chirag64
Chirag Bhatia - chirag64

Reputation: 4516

You can try using window.onbeforeunload for Chrome.

Or use jQuery bind function with onbeforeunload event.

Upvotes: 1

Related Questions