| | |
Detect browser window closing event in Firefox -
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
I think that "load/unload" the document is the only appropriate notion to use in situations when:
1. user is closing the current page [ap dependable op] currently associated with ap. close;
2. the user is loading [as a final step of download, cache, parse, render procedure] a New Page in the same docked browser window (called browser tab while in fact being just another instance of an independent dock-able browser window), causing the previous page to be unloaded from active memory and free the space previously taken by its content.
3. Moving back and forth the browser history, inside the same tab/docked window, should be considered as load/unload process, -moreover, this action should factually cause the page to get "loaded/unloaded" from active memory, snce it already exists in a browser cache and there is absolutely no practical reason to leave it "eat" your system resources as last generation browsers do.
This undoubtedly means that: if the user closed the page he was on (although I don't know if there is such browser providing that option), opened another page in the same window/browser tab, navigated back and forth, should all actually carry out the task, to unload/load content, while, same time triggering corresponding events. But I think that browser close should be discerned from document close which is an equivalent of page unload, but this two different actions/events have in practice, the same meaning for the page content therefore right now it is unnecessary to discern. Although browser close and /or tab close comparing to page close/unload, should have different meanings on the browser domain, wihch I believe are already differentiated.
*
But it's a completely different story when (ctrl) tabbing or alt+tabbing between browser windows containing data. This doesn't fall in navigating category. In this case: only the screen display gets redrawn, but nothing else. No events should fire nor any other action be carried out except window/tab focus with any other focus event aliases. Meaning, only the conventional (focus/blur) events should fire. Smart browsers will during this event (focus) check if any content changes have occurred on the side of source provider and update if specified or some other way required.
Generally speaking There's nothing more efficient than loading pages from browser cache. Keeping them in memory causes what f.i. firefox users are complaining the most: memory leaks.
Regards.
1. user is closing the current page [ap dependable op] currently associated with ap. close;
2. the user is loading [as a final step of download, cache, parse, render procedure] a New Page in the same docked browser window (called browser tab while in fact being just another instance of an independent dock-able browser window), causing the previous page to be unloaded from active memory and free the space previously taken by its content.
3. Moving back and forth the browser history, inside the same tab/docked window, should be considered as load/unload process, -moreover, this action should factually cause the page to get "loaded/unloaded" from active memory, snce it already exists in a browser cache and there is absolutely no practical reason to leave it "eat" your system resources as last generation browsers do.
This undoubtedly means that: if the user closed the page he was on (although I don't know if there is such browser providing that option), opened another page in the same window/browser tab, navigated back and forth, should all actually carry out the task, to unload/load content, while, same time triggering corresponding events. But I think that browser close should be discerned from document close which is an equivalent of page unload, but this two different actions/events have in practice, the same meaning for the page content therefore right now it is unnecessary to discern. Although browser close and /or tab close comparing to page close/unload, should have different meanings on the browser domain, wihch I believe are already differentiated.
*
But it's a completely different story when (ctrl) tabbing or alt+tabbing between browser windows containing data. This doesn't fall in navigating category. In this case: only the screen display gets redrawn, but nothing else. No events should fire nor any other action be carried out except window/tab focus with any other focus event aliases. Meaning, only the conventional (focus/blur) events should fire. Smart browsers will during this event (focus) check if any content changes have occurred on the side of source provider and update if specified or some other way required.
Generally speaking There's nothing more efficient than loading pages from browser cache. Keeping them in memory causes what f.i. firefox users are complaining the most: memory leaks.
Regards.
but wat is the solution
Help as an alias
I think programming is great................
Tour Travel weblink by me and about Tour ,
Go To My Home Page and I m in Webdevelopment.
I think programming is great................
Tour Travel weblink by me and about Tour ,
Go To My Home Page and I m in Webdevelopment.
•
•
Join Date: Nov 2008
Posts: 2
Reputation:
Solved Threads: 1
Seems my solution is better.
Set the jmp to define jump or not.
It works fine in IE but partially in Firefox.
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<head> <script> var jmp=false; function jmp(){ if(jmp){ location.href='ExecCmd?exitClr=1'; } } </script> </head> <body onload="change();" onunload="jmp();"> </body>
Set the jmp to define jump or not.
It works fine in IE but partially in Firefox.
Ok, guys, why do we need such a word fight for nothing?
Actually I did not understand what is exactly the requirement - I mean, does the guy want to have the code work in any browser window on closing it, or he just wants to do something upon closing a specific window only.
If he needs to do something only in a specific window, he can call the specific window using window.open() - just like a popup.... Then the window.close() method will close only this specific window.
As the window.close() can be called within another function, the guy can just create a new closing function, linked on a specific close button.
So it looks like
function myclosingfx()
{
do whatever i want to do;
if (doing this successful)
{
window.close();
}
}
Then just put a button on top of the page - close me with action onclick="myclosingfx()"
And that's that.
Unfortunately as far as I know onunload cannot distinguish between navigating to another page or simply closing the window, so I think it cannot be used in this case. So I don't have a solution for let's say - any browser window...just for the popus...
Actually I did not understand what is exactly the requirement - I mean, does the guy want to have the code work in any browser window on closing it, or he just wants to do something upon closing a specific window only.
If he needs to do something only in a specific window, he can call the specific window using window.open() - just like a popup.... Then the window.close() method will close only this specific window.
As the window.close() can be called within another function, the guy can just create a new closing function, linked on a specific close button.
So it looks like
function myclosingfx()
{
do whatever i want to do;
if (doing this successful)
{
window.close();
}
}
Then just put a button on top of the page - close me with action onclick="myclosingfx()"
And that's that.
Unfortunately as far as I know onunload cannot distinguish between navigating to another page or simply closing the window, so I think it cannot be used in this case. So I don't have a solution for let's say - any browser window...just for the popus...
" Of all the things I've lost,
I miss my mind the most...."
Mark Twain
I miss my mind the most...."
Mark Twain
•
•
Join Date: Nov 2009
Posts: 3
Reputation:
Solved Threads: 0
Hi,
Even I am trying the browser close event for cross browser and this should trigger only when X button is clicked or page is refreshed. Here's the code I am using but it only works in IE:
=====================
========================
I know the issue is because of window.events and ClientX/ClientY.
Could someone please fix my code to make it work in all browsers? This is very urgent and have been striving since 3 days...
*Please Note: Current code is working in IE only and to check you have to close the browser window or refresh the page with mouse click.
Even I am trying the browser close event for cross browser and this should trigger only when X button is clicked or page is refreshed. Here's the code I am using but it only works in IE:
=====================
html Syntax (Toggle Plain Text)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><head> <title>Warning Test</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Style-Type" content="text/css"> <meta http-equiv="Content-Script-Type" content="text/javascript"> <script language="JavaScript"> // warning message javascript var isOpera, isIE, isNav, isFox, isOther = false; if (navigator.userAgent.indexOf("Opera") != -1) { isOpera = true; } else if (navigator.userAgent.indexOf("Firefox") != -1) { isFox = true; } else if (navigator.appName == "Microsoft Internet Explorer") { isIE = true; } else if (navigator.appName == "Netscape") { isNav = true; } else { isOther = true; } if (isIE || isOpera || isNav || isFox || isOther) { window.onbeforeunload = WarnUser; function WarnUser() { OffsetX = window.event.clientX; OffsetY = window.event.clientY; if (((window.event.clientX < 0) || (window.event.clientY < 0)) && (isWarnUser == true)) { event.returnValue = " "; //window. önunload = sessionInvalidate; } else { // Reset the flag to its default value. isWarnUser = true; } } } </script> </head> <body> <script type="text/javascript"> var isWarnUser = true; </script> test </body> </html>
I know the issue is because of window.events and ClientX/ClientY.
Could someone please fix my code to make it work in all browsers? This is very urgent and have been striving since 3 days...
*Please Note: Current code is working in IE only and to check you have to close the browser window or refresh the page with mouse click.
Last edited by peter_budo; 24 Days Ago at 6:58 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)
![]() |
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Random Images on Refresh
- Next Thread: Dynamic Ajax Content and Jquery
| Thread Tools | Search this Thread |
ajax ajaxcode ajaxexample ajaxhelp ajaxjspservlets animate automatically beta box browser bug calendar captchaformproblem checkbox child class close column cookies createrange() css cursor debugger dependent disablefirebug dom download dropdown editor element embed engine error events explorer ext file form forms google gwt gxt hiddenvalue highlightedword hint html htmlform ie7 ie8 iframe images internet java javascript javascripthelp2020 jawascriptruntimeerror jquery jsf jsfile jump libcurl math media microsoft mimic object onmouseoutdivproblem onreadystatechange parent paypal pdf php player position post problem programming progressbar regex runtime scroll search security select session shopping size software sql text textarea unicode w3c web website window windowofwords windowsxp wysiwyg \n





