Friday, January 23, 2015

onbeforeonload event in firefox

There is a difference in onbeforeunload event across the version of Firefox browser. Normally we are using "alert" function to identify whether that particular function is calling or not. But in case of onbeforeunload event, alert will work upto firefox version 26.0. If the firefox version is greater than 26.0, alert funtion will not work. So if you want to use onbeforeunload event in firefox which is greater version of 26.0, then don't use alert function, just write your logic and test it.

<html> <head> <script> function onBrowserClose() { alert("Browser is closing"); // This will work, if your firefox version is less than or equal to 26.0 //Your logic } </script> </head> <body onbeforeonload="onBrowserClose()"> Browser close test... </body> </html>
If your Browse is latest version of firefox (greater than 26.0). Just remove the alert from above code.
<html> <head> <script> function onBrowserClose() { //Your logic } </script> </head> <body onbeforeonload="onBrowserClose()"> Browser close test... </body> </html>

No comments:

Post a Comment