Awanka Posted July 11, 2007 Share Posted July 11, 2007 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. Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted July 16, 2007 Share Posted July 16, 2007 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.