Skip to main content
Inspiring
August 15, 2012
Answered

CGI variables -<CFIF CGI.HTTP_USER_AGENT IS IE8 OR IE9>

  • August 15, 2012
  • 1 reply
  • 2505 views

I need to find code that if a user is using Internet explorer 5, Internet explorer 6, Internet explorer 7 or Internet explorer 8 they get redirected to one page and if the are using any other browser including IE9  they go to another.

Something like this

<CFIF CGI.HTTP_USER_AGENT IS IE5 OR CGI.HTTP_USER_AGENT IS IE6 OR CGI.HTTP_USER_AGENT IS IE7 OR CGI.HTTP_USER_AGENT IS IE8 >

<cflocation go here>

<cfelse>

<cflocation go here>

</cfif>

Any help ?

    This topic has been closed for replies.
    Correct answer p_sim

    Go to this Web page to see a full list of http_user_agent for Internet Explorer.

    http://www.useragentstring.com/pages/Internet%20Explorer/

    <cfif cgi.http_user_agent CONTAINS "MSIE 5"

         OR cgi.http_user_agent CONTAINS "MSIE 6"

         OR cgi.http_user_agent CONTAINS "MSIE 7"

         OR cgi.http_user_agent CONTAINS "MSIE 8">

         <!--- redirect to page A --->

    <cfelse>

         <!--- redirect to page B --->

    </cfif>

    As you can see, there is a pattern in the user agent string. You might want to use Regular Expression (Regex) to simplify the conditional clause.

    <cfif

    1 reply

    p_sim
    p_simCorrect answer
    Participating Frequently
    August 16, 2012

    Go to this Web page to see a full list of http_user_agent for Internet Explorer.

    http://www.useragentstring.com/pages/Internet%20Explorer/

    <cfif cgi.http_user_agent CONTAINS "MSIE 5"

         OR cgi.http_user_agent CONTAINS "MSIE 6"

         OR cgi.http_user_agent CONTAINS "MSIE 7"

         OR cgi.http_user_agent CONTAINS "MSIE 8">

         <!--- redirect to page A --->

    <cfelse>

         <!--- redirect to page B --->

    </cfif>

    As you can see, there is a pattern in the user agent string. You might want to use Regular Expression (Regex) to simplify the conditional clause.

    <cfif