Detecting the browser type - on the server side The article is some good code for detecting the browser type - on the server side. Itdelivers the right page while processing based on the browser type intsead of doing aredirect while the page is loading. It sends IE5 one way, IE4 another way, (or IE4& IE5 the same way), and everybody else another way. This is just one way ofcoding to really be detailed to which browser the user is using. Here is the Code <%@ Language=VBScript %>
<% Dim sAgent,b_IE,b_Vers,b_Mac,b_Nav,b_Other Dim ie4win,b_win,ie4,ie3,ie4mac,ns4
b_IE=false b_Nav=false b_Other = false b_Vers = 0 sAgent = Request.ServerVariables("HTTP_USER_AGENT")
if (inStr(sAgent,"MSIE")>0) then b_IE=true b_Vers = Mid(sAgent,inStr(sAgent,"MSIE")+5,1) elseif (inStr(sAgent,"MSPIE")>0) then b_Vers = Mid(sAgent,inStr(sAgent,"MSPIE")+9,1) else b_Vers = Mid(sAgent,9,1) end if
if (not (b_IE)) then b_Nav=inStr(sAgent,"Mozilla")>0 or inStr(sAgent,"compatible")>0 end if
b_Win = (instr(sAgent,"Win")) > 0 'Windows b_Mac = (instr(sAgent,"Mac")) > 0 'Mac b_Other = not (b_Win or b_Mac) 'Other
ie4 = b_IE and b_Vers>=4 ' IE4 ie5 = b_IE and b_Vers>=5 ' IE5 ie3 = b_IE and b_Vers<4 ' Everything <IE4 we consider IE3 ie4Mac = b_Mac and ie4 ' IE4 Mac ns4 = b_Vers>=4 and b_Nav ' NS4 ie4Win = b_Win and ie4 and not b_mac ' IE4 Windows %>
<%
if ie5 then ' Send this File to IE5 response.write("simple1.htm") elseif (ie4) then ' Send this File to IE4 response.write("simple2.htm") else ' Send this File to other browsers response.write("simple3.htm") end if %> |
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
More ASP Code Articles More By aspfree developerWorks - FREE Tools! | Learn to enable users to both rate existing animations and to combine existing animations into new snippets. This is the third in a series of three tutorials that chronicle the building of a site that enables collaborative discussion and animation building using Domino and OpenLaszlo. FREE! Go There Now!
| | | | Build secure Web services with transport-level security using IBM Rational Application Developer V7 and IBM WebSphere Application Server V6.1. Follow this three-part series for step-by-step instructions about how to develop Web services and clients, configure HTTP basic authentication, and configure HTTP over SSL (HTTPS). This first part of the series walks you through building a Web service for a simple calculator application. You generate and test two different types of Web services clients: a Java Platform, Enterprise Edition (Java EE) client and a stand-alone Java client. You also handle user-defined exceptions in Web services. FREE! Go There Now!
| | | | Manage, govern, and share services across your organization by using WebSphere Service Registry and Repository. Follow the hands-on exercises to learn how to navigate the Web interface to publish, find, reuse, and update services. FREE! Go There Now!
| | | | Analysts, architects, and developers who have existing COBOL or PL/I skills and want to extend those skills to deploy new workloads on the mainframe can use the IBM Enterprise Modernization Sandbox for System z to find hands-on walkthroughs of common real world scenarios. The scenarios provide examples of how to rapidly design, create, assemble, test, and deploy high-quality Web, Web services, portal, and SOA applications for IBM CICS, IBM IMS, and IBM WebSphere Application Server. FREE! Go There Now!
| | | | XML has become a common way of storing business data as flat files and many data server vendors including IBM have provided ways to store this data within relational database systems. Increasingly collections of XML files are accessed like databases using an xQuery and other XML standard mechanisms. Businesses find the need to combine the traditional tabular structured data with XML formatted data. In this webcast, you’ll learn about IBM’s WebSphere Federation Server technology, which provides users with the ability to integrate these two data formats. FREE! Go There Now!
| | | | Learn how to do more with your reusable assets with the free Rational Asset Manager eKit. The eKit includes demos on how Rational Asset Manager tracks and audits your assets in order to utilize them for reuse. Plus you’ll find white papers and a Webcast that discuss the challenges of a Service Oriented Architecture and how Rational Asset Manager can provide quick and effective solutions. FREE! Go There Now!
| | | | Rational Modeling Extension for Microsoft .NET enhances usability for code generation supporting a more intelligent refactoring. The latest enhancements enable organizations with Java and .NET systems and software development maintain architectural integrity across heterogeneous platforms. FREE! Go There Now!
| | | | Get a free trial download of the latest version of IBM Rational Performance Tester V7.0.1, a load and performance testing solution for teams concerned about the scalability of their Web-based applications. Combining multiple ease-of-use features with granular detail, Rational Performance Tester simplifies the test-creation, load-generation and data-collection processes that help teams ensure the ability of their applications to accommodate required user loads. FREE! Go There Now!
| | | | Join the IBM Watchfire team for an informative discussion on techniques and best practices to proactively manage Web application security and how to effectively build application security testing into the software development lifecycle (SDLC). In this Software Delivery Platform webcast you will learn: How to better understand potential web application security vulnerabilities, best practices and how to effectively integrate application security testing into the software development lifecycle, the importance of detecting and removing software vulnerabilities during application development. FREE! Go There Now!
| | | | In this webcast, you'll get an introduction to the eXtreme Transaction Processing (XTP) features of WebSphere Extended Deployment and the common architectural traits required by XTP applications. See how WebSphere Extended Deployment's ObjectGrid feature provides a state-of-the-art infrastructure for hosting XTP applications. FREE! Go There Now!
| | | | All FREE IBM® developerWorks Tools! | |