Click to See Complete Forum and Search --> : OnBeforeUnload Popup - Exit function if search button is clicked


stoi2m1
May 30th, 2008, 01:17 AM
I have an OnBeforeUnload popup function working. But I would like the function to exit before displaying the message if the search button on the page is clicked.

window.onbeforeunload = confirmexit();

function confirmexit()
{
//do something

if (search button clicked)
{
end function
} else {
return exitMessage;
}

}

How do I determine if the search button is clicked.

Thank You,
Jesse

PeejAvery
May 30th, 2008, 07:10 AM
In theory, you could create a global variable which is changed when someone clicks the search button. Then you would need a function within the confirmexit() function which is being looped by setInterval(). That function inside would have to check for the global variable.

I'm not even sure if that would work because the return would most likely be for itself and not the enclosing confirmexit() function.

stoi2m1
May 30th, 2008, 08:16 AM
I found a solution to this. I used the onclick attribute of the input to set onbeforeunload=null

Code:
<form>
<input type="button" value="Search" onlick="onbeforeunload=null">
</form>

Thanks for the info,
Jesse