Jump to content

Need an event handler for when a popup closes that is not onunload


Awanka

Recommended Posts

I have a popup window full of php, and in it is this piece of code which executes when the window closes..

 

<body "javascript:void(0)" onUnload=<?php $dashVars['firstTime'] = 'T'; DashboardDB::saveDashboardSession($dashVars)?>>

 

It works fine except I also have another line of code in the php that submits the form to itself

 

$htmlOut.= "<td><input type=\"checkbox\" name=\"checkAll${metricType}\" value=\"true\" onclick=\"submit();\"";

 

And whenever this line of code executes, refreshing the popup window, the onUnload event will trigger.

 

I need an event trigger for when the popup wnidow really closes and not just when it's being refreshed.  Please help.

 

 

Simple.

 

Create a global var named formSubmit and initially set the value to false.  In the onunload handler, if formSubmit is set to true, return early and do not execute any code.  Then create an onsubmit handler for your form and in there set the global variable formSubmit to true.  Now the unload even will only trigger when the form is not being submitted.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.