Link to home
Start Free TrialLog in
Avatar of rivkamak
rivkamakFlag for United States of America

asked on

onclick cancel another function

I have a function that runs onunload.
Is there a way that when someone clicks a different button on the page, and it runs a different function, is there a way to cancel and make sure the onunload won't run?
Avatar of leakim971
leakim971
Flag of Guadeloupe image

>is there a way to cancel and make sure the onunload won't run

use a input with type = button
and not a submit button

set the onclick attribute of this button to run the different function
Avatar of zappafan2k2
zappafan2k2

Try adding
window.onunload=null;

Open in new window

somewhere in your function to cancel the onunload call.
<input type="button" onclik="a_different_function()" value="no unload" />

Open in new window

leakim971,

I think rivkamak is looking for a way to cancel the onunload call.  There seems to already be a function called when a button is clicked.

In your example (onclik should be onclick, I think), in  a_different_function() adding the line I posted above would cancel the onunload function.
Avatar of rivkamak

ASKER

My onlick submits the page. But I don't want the onunload to happen when you click the submit button.
If the form submits but I put value="no unload", then the unload wont' happen?
ASKER CERTIFIED SOLUTION
Avatar of zappafan2k2
zappafan2k2

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial