473,396 Members | 2,106 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,396 software developers and data experts.

Browser detection

I have a javascript function to log out users if they do not refresh page for 45 minutes.
Expand|Select|Wrap|Line Numbers
  1. (function() 
  2. {
  3.   setTimeout('newWindow()',3000000);
  4.   setTimeout('logout()', 3600000);
  5. }());
  6.  
But this function getting executed unexpectedly for SAFARI browser. As a workaround for this I decided to ignore this code for SAFARI browser by using a code which detect browser as mentioned below.
Expand|Select|Wrap|Line Numbers
  1. if (navigator.userAgent.indexOf("Safari")==-1 ) 
  2.         {
  3. (function() 
  4. {
  5. setTimeout('newWindow()',3000000);
  6. setTimeout('logout()', 3600000);
  7. }());
  8. }
  9.  
But the below mentioned line
Expand|Select|Wrap|Line Numbers
  1. if (navigator.userAgent.indexOf("Safari")==-1 ) 
also detecting CHROME as a SAFARI.

So the above code not getting executed for SAFARI as well as CHROME, But I want it to get executed for all the browser except SAFARI.

Basically, I have two requirements.
1. Function should work properly for SAFARI also
OR
2. Function should be executed for all the browser except SAFARI.

Thanks in advance.

Swapnil
May 6 '10 #1
1 1497
gits
5,390 Expert Mod 4TB
what does 'getting executed unexpectedly for SAFARI browser' mean? could you elaborate on that a bit more?

another note: to avoid useless evals you simply might call:
Expand|Select|Wrap|Line Numbers
  1. window.setTimeout( newWindow, 3000000 );
the first param for the setTimeout-method is a function reference and the second is the delay ... when you pass a string to the function it needs to be evaluated which is just overhead.

basicly the setTimeout() method should work in all browsers ... so please explain what 'unexpectedly' means in your case.

kind regards
May 7 '10 #2

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

Similar topics

5
by: Mike Gifford | last post by:
Hello, htmlArea3 is a great script for those who want a free javascript WYSIWYG editor. The only problem is that it only works in Mozilla 1.3+ & IE 5.5+. I'd like to find some piece of...
4
by: delerious | last post by:
I want to know the height of the viewable portion of a page (minus scrollbar) in Opera and Mozilla. For Opera, I could use document.body.clientHeight. Unfortunately, this won't work in Mozilla...
7
by: Michael Winter | last post by:
As many of you know, IE has poor support for CSS 2, including the dynamic pseudo-class, :hover. This could easily be emulated with an intrinsic event, but how can you tell that it's required? You...
0
by: Carlos | last post by:
Hi all, I am currently able to detect the browser capabilities, and determine if a browser is from a mobile device. However, I only have been able to place this detection code in an aspx page....
12
by: jnc3196 | last post by:
Help needed, the script below detects the correct browser but doesn't select the correct CSS file. Also how to call it from an external js file so as not to repeat it in every page. <html>...
1
by: jaydev | last post by:
Hi, I am looking for code to detect and redirect to the corresponding browser download page if the clients uses old version, could anyone have a sample code for this? I want to use the...
4
by: sjpolak | last post by:
sorry, I put the original text instead of my changed one in the previous mail sorry hello, I am new to this forum and a laymen. I have awebsite www.earlyflute.com. I make baroque flutes as you...
5
by: Roger | last post by:
Hi all Can anyone point me in the right direction for drowser detgection, I can't use javascript as i understand mobile phones etc, java is mostly turned of bu default Thanks for the help in...
9
by: Max58kl | last post by:
Hi I am trying to use browser detection to load browser specific web pages. The first part always seems to work ok, the Firefox page loads correctly. Everytime I try to load the page in IE7...
10
by: Conrad Lender | last post by:
In a recent thread in this group, I said that in some cases object detection and feature tests weren't sufficient in the development of cross-browser applications, and that there were situations...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.