Solved

browser detection script

Posted on 2003-10-21
6
172 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
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

Save the day with this special offer from ATEN!

Save 30% on the CV211 using promo code EXPERTS30 now through April 30th. The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

734 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