Solved

browser detection script

Posted on 2003-10-21
6
159 Views
Last Modified: 2013-12-24
i need to make a browser detection script, and instead of trying to analyze all the user-agent strings myself, i figured that someone out there has probably already done the work.  i need it to detect all the latest browsers (i.e. Netscape 7 vs. 6 vs. 4.x)

if you have a script that isn't in CFML it is okay as long as i can see the algorithm you used

thanks,

justin
0
Comment
Question by:newstandard
6 Comments
 
LVL 9

Expert Comment

by:CFDevHead
ID: 9591402
here something simple and it works

function browserRedirect()
{
  var ns4 = document.layers;
  var ns7 = document.getElementById && !document.all;
  var ie6 = document.all;
 
  if(ns4) URLStr = "1.html";
  else if(ns7) URLStr = "2.html";
  else if(ie6) URLStr = "3.html";
  else URLStr = "4.html";
  location = URLStr;
}
browserRedirect()
0
 

Author Comment

by:newstandard
ID: 9591502
i need something that can be done using analysis of the UserAgent string because i am doing something server side - that means i can't use javascript
0
 
LVL 17

Accepted Solution

by:
anandkp earned 250 total points
ID: 9592402
using HTTP_User_Agent -
u'll need to send the information to the server [thru form submit or url ... whatever]

Parse the string & chk for the existance of MSIE [indicates its a IE] else its a NetScape.
there u'll also see the version number ...

I dont know what opera or other browsers show up :)

0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 11

Expert Comment

by:hart
ID: 9596659
anand is right :-)

for server side check
<CFIF FINDNOCASE("MSIE",HTTP_USER_AGENT) EQ 0>            
   not ie
</CFIF>

Regards
Hart
0
 

Expert Comment

by:dvsmind247
ID: 9597264
There's a pretty good custom tag that already does this called <cf_whodat>.

Here's the link:http://www.teratech.com/ColdCuts/cutdetail.cfm?cutid=296

~cheers
dvsmind247
0
 

Expert Comment

by:watersdm
ID: 9608033
Don't waste your time with half-baked, half-working solutions. If browser detection is important to you then spend a few hundred dollars on a reliable, comprehensive solution such as Browserhawk (http://www.browserhawk.com).

David
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now