DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   JavaScript / DHTML / AJAX (http://www.daniweb.com/forums/forum117.html)
-   -   close event for firefox (http://www.daniweb.com/forums/thread53645.html)

fuehrer Aug 29th, 2006 12:55 am
close event for firefox
 
Hi guys,

i'm new to JS and need a little help on this issue of mine.....

i'm trying to popup a confirm dialog box whenever i close my browser window,the problem is that i'm able to do this in IE but i'm having problems when i'm using firefox.i'm doing this using the "onbeforeunload" event.........

Please do gimme a solution to this problem in forefox and also let me know y this is happening.................


The script that i've ritten is :
[html]
<script language="JavaScript">

function ConfirmLeaving()
{
if (event.clientY < 0 && event.clientX > 600)
{
var answer = confirm ("do u want to go to google?");
if (answer)
{
window.open("http://www.google.com");
}
}
}
</script>

</HEAD>
<body onbeforeunload="ConfirmLeaving();">[/html]

mostafadotnet Aug 29th, 2006 6:12 am
Re: close event for firefox
 
Hi fuehrer,
if you check this code using firefox in Javascript Console,you'll figure out that it throws this error:
Quote:

Error: event is not defined
So,it won't work in firefox till you change the onbeforeunload event.
Good luck.


All times are GMT -4. The time now is 9:00 am.

Forum system based on vBulletin Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
©2003 - 2010 DaniWeb® LLC