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! | Hold your calendar on January 30, 2008 for this free webcast on the new i5/OS. Rational's Enterprise Modernization products will be discussed at this webcast as they help to drive the application development environment for this new System i OS. <br />And learn how i5/OS will take you to the next step of efficient, resilient business processing. You will hear about the new i5/OS capabilities as it will be the most significant i5/OS release in years. If you cannot join the webcast on 1/30/08 you can still use this link to listen to the replay.<br /> FREE! Go There Now!
| | | | The IBM DB2 Deep Compression ROI tool is designed for DBA’s and IT management personnel to perform a clinical analysis of the cost savings gained from the Storage Optimization feature of DB2 9 for Linux, UNIX and Windows. The feature, also known as Deep Compression, compresses data that lies within a database by up to 80% at times. FREE! Go There Now!
| | | | Visit IBM developerWorks to download a free trial version of WebSphere Business Modeler Advanced V6.1.1, IBM’s premier business process modeling and analysis tool for business users that offers process modeling, simulation, and analysis capabilities. IBM WebSphere Business Modeler helps you visualize, understand, and document business processes for continuous improvement. FREE! Go There Now!
| | | | Visit IBM developerWorks to download IBM DB2 Express-C 9.5, a no-charge version of DB2 Express 9 database server. DB2 Express-C offers the same core data server base features as other DB2 Express editions and provides a solid base to build and deploy applications developed using C/C++, Java, .NET, PHP, and other programming languages. FREE! Go There Now!
| | | | Download the IBM WebSphere Portal V6.1 beta code and learn more about the rich features and enhancements in IBM WebSphere Portal V6.1. WebSphere Portal provides a composite application or business mashup framework and the advanced tooling needed to build flexible, SOA-based solutions, and scalability to meet the needs of any size organization. FREE! Go There Now!
| | | | Visit IBM developerWorks to download a free trial of the Rational Host Access Transformation Services (HATS) Toolkit. The HATS toolkit provides a set of plug-ins for the IBM Rational Software Delivery Platform to help you easily extend your legacy applications. HATS makes your 3270 and 5250 applications available as HTML through the most popular Web browsers, while converting your host screens to a Web look and feel and it also enables you to develop new Web, portal, and rich-client applications. FREE! Go There Now!
| | | | Portfolio Management is about effectively managing portfolio value by aligning portfolio investments with business goals. This complimentary e-kit provides a collection of materials that can help you understand how IBM Rational enables and automates best practices for improved governance and clear visibility into portfolio and project performance across the entire IT project lifecycle. FREE! Go There Now!
| | | | In this webcast, IBM Rational will discuss the importance of Web application security and will share techniques and best practices to introduce application security testing into current QA processes including: understanding common security vulnerabilities and techniques to integrate security testing with defect tracking and remediation systems in an effort to safeguard sensitive online information. FREE! Go There Now!
| | | | WebSphere Process Server delivers a unique integration framework that simplifies existing IT resources. Often, as IT assets grow to support business demand, so too does their complexity and manageability. In this webcast, we’ll discuss how WebSphere Process Server helps deliver an SOA infrastructure that provides a common model to orchestrate, mediate, connect, map, and execute the underlying IT functions. Discover how WebSphere Process Server simplifies integration of business processes by leveraging existing IT assets as reusable services without the complexities of traditional integration methodologies. FREE! Go There Now!
| | | | Viper 2 brings a great value to developer communities including SQL, XML, PHP, Ruby, .NET and Java. You probably already know that DB2 Express-C is free for developers to develop, deploy and distribute. Viper 2 provides a variety of means that help move your application from the development stage to deployment more rapidly. This webcast shows how to best utilize the latest tools available for developing DB2 applications. FREE! Go There Now!
| | | | All FREE IBM® developerWorks Tools! | |