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.

 

 

Link to comment
Share on other sites

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.

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.