Detecting Browser Types

Post Reply
SearchesLot
Posts: 10
Joined: Thu Aug 29, 2002 3:14 pm

Detecting Browser Types

Post by SearchesLot »

I would like to put the following metas into the html of search results

For IE browser:
<meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">

For Netscape browser:
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">

I know I can use the $HTTP_USER_AGENT to determine the browser but there are so many different user agents, is there any way to make sure it's just Netscape or IE? I assume I would use something like this:
<If $HTTP_USER_AGENT like "">
<meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">
<Else>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</if>

Is there any other way to do it? Would it be better to do this in Apache instead?

Thank you for any assistance.
Gerry
User avatar
John
Site Admin
Posts: 2622
Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH
Contact:

Detecting Browser Types

Post by John »

The simplest way to detect IE is similar to what you have: <if $HTTP_USER_AGENT like 'msie'><$isie=1></if>
It can of course be fooled if the user sets their own user agent string.

I'm assuming that you will be sending different data to each browser as well if you are using different charsets?
John Turnbull
Thunderstone Software
Post Reply