[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Browser Detection / Redirection : (pointer to original Q - 125 pts)

Posted on 2004-08-11
1
Medium Priority
?
264 Views
Last Modified: 2013-12-24
0
Comment
Question by:stu215
[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
1 Comment
 
LVL 2

Accepted Solution

by:
rlavalle earned 80 total points
ID: 11785615
Here you go...

Here'a solution using ColdFusion and a tiny bit of JavaScript. ColdFusion has a CGI variable called HTTP_USER_AGENT that holds the browser name and version near the end. I parse this string and check for each of the 3 browser types and their version. You can easily open a ColdFusion page in any browser you want to compare against and determine where in the HTTP_USER_AGENT string the browser name and version is (in case you need to change this in the future).

Oh, and I used the latest version of Safari that I think has been released (125.9) rather than 128.5.

Good luck,
Russ

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<cfscript>

function IsBrowserValid()
{
     browserLoc = 0;
     versNum = 0;
     safari = "Safari";
     msie = "MSIE";
     netscape = "Netscape";
     goodBrowser = false;
     
     browserLoc = FindNoCase(safari, CGI.HTTP_USER_AGENT);
     if (browserLoc)
     {
          versNum = Val(RemoveChars(CGI.HTTP_USER_AGENT, 1, browserLoc + LEN(safari)));
          if (versNum GTE 125.9)
               goodBrowser = true;
     }
     else
     {
          browserLoc = FindNoCase(msie, CGI.HTTP_USER_AGENT);
          if (browserLoc)
          {
               versNum = Val(RemoveChars(CGI.HTTP_USER_AGENT, 1, browserLoc + LEN(msie)));
               if (versNum GTE 6)
                    goodBrowser = true;
          }
          else
          {
               browserLoc = FindNoCase(netscape, CGI.HTTP_USER_AGENT);
               if (browserLoc)
               {
                    versNum = Val(RemoveChars(CGI.HTTP_USER_AGENT, 1, browserLoc + LEN(netscape)));
                    if (versNum GTE 7)
                         goodBrowser = true;
               }
          }
     }
     
     return goodBrowser;
}
</cfscript>

<script language="javascript1.2">
<cfif IsBrowserValid()>
          alert('Browser is valid. You may continue.');
<cfelse>
          alert('Browser is INVALID. You must go away.');
          window.location = "http://www.google.com";
</cfif>
</script>

</body>
</html>
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

656 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