473,325 Members | 2,480 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

detecting browser close issue

how to find it in safari, chrome browser through javascript
to call serverside methods from clientside functions.

i need eaualvent coding for safari chrome firefox
this coding
here is sample code to call serverside code from javascript

Expand|Select|Wrap|Line Numbers
  1.   <script language="javascript" type="text/javascript">
  2.         window.onbeforeunload = function (evt) {
  3.             var brow = navigator.appName;
  4.  
  5.             alert(brow);
  6.             if (brow == "Microsoft Internet Explorer") { // IE
  7.  
  8.                 if (window.event.clientX < 0 || window.event.clientY < 0) {
  9.                     PageMethods.Message();
  10.                     alert("You are navigate away from this page\n\n Press OK to Continue?");
  11.  
  12.                 }
  13.                 else if (evt.altKey && evt.keyCode == 115) {
  14.                     alert("You are navigate away from this page\n\n Press OK to Continue?");
  15.                     PageMethods.Message();
  16.                 }
  17.             }
  18.             else if (brow == "Netscape") { // FF
  19.                 var tempXX = getMouse(this);
  20.                 if (tempXX <= 10) {
  21.                     alert("You are navigate away from this page\n\n Press OK to Continue?");
  22.                     PageMethods.Message();
  23.                 }
  24.                 else if (evt.altKey && evt.keyCode == 115) {
  25.                     alert("You are navigate away from this page\n\n Press OK to Continue?");
  26.                     PageMethods.Message();
  27.                 }
  28.  
  29.             }
  30.         }
  31.     </script>
  32.  
  33.  
  34.  
  35. <script type="text/javascript">
  36.         var posx; var posy;
  37.         function getMouse(e) {
  38.             //posx = 0; posy = 0;
  39.             var ev = (!e) ? window.event : e; //IE:Moz
  40.             if (ev.pageX) {//Moz
  41.                 posx = ev.pageX + window.pageXOffset;
  42.                 posy = ev.pageY + window.pageYOffset;
  43.             }
  44.             else if (ev.clientX) {//IE
  45.                 posx = ev.clientX + document.body.scrollLeft;
  46.                 posy = ev.clientY + document.body.scrollTop;
  47.             }
  48.  
  49.             return posy; 
  50.         }
  51.         document.onmousemove = getMouse
</script>
Oct 3 '11 #1
1 2225
acoder
16,027 Expert Mod 8TB
Don't use browser detection. Try the top current article: http://bytes.com/topic/javascript/in...vascript-event
Oct 13 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Frances Del Rio | last post by:
pls, why is this not working? <SCRIPT language=JavaScript type="text/javascript"> var br = '<SCRIPT language=Javascript' br += 'src="js_pop.js" type="text/javascript">' br += '</SCRIPT>' var...
1
by: Al Fraser | last post by:
Hope someone can help. My situation is this: I have x number of ASPs that form a 'sales process'. What I want to be able to do is detect when the user has left our 'sales process' (so I can...
4
by: Champika Nirosh | last post by:
Hi All, I have a asp .net app and it is a online test application so tracking the user behaviour is very important. The problem is in what way I can identify the user logoff time if it happens...
3
by: Denon | last post by:
How to trap browser close event in SERVER side? I read a lot of forum message, it talk about onclose(), onunload() and even onbeforeunload() event. However, all of theses are based on javascript...
2
by: Sunil Sabir | last post by:
Dear All, I have a Main Asp.Net page . In that Page I have a Tab Strip which has SIX tabs each representing a different web Forms.So that when a user clicks different tab he can navigate between...
4
by: mammen | last post by:
Hello, I'm writing trace log of various actions happening in my ASP.NET web application by opening a text file when the user logs in to the system and closing the file while the user logs out....
1
by: bloodandrose | last post by:
Can you help me How to detect browser close event? Thanks
3
by: somaskarthic | last post by:
Hi I am trying to use Javascript in order to detect when a user presses the little 'X' at the top right hand corner of the window or uses File..Close, in order to process some code before hand....
1
by: Mango | last post by:
I'm trying to print some text in a very specific position on a page, so that it will show through the window of an envelope when folded. This is easy to do, as long as the browser's print margins...
1
by: sreedhardasi | last post by:
Hi, I would like to call a javascript function when user clicks on browser's close button. Here is the scenario. 1. User clicks browser close button. 2. User will be displayed a popup or a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.