[thelist] http_user_agent

Paul Backhouse paul.backhouse at 2cs.com
Thu Mar 21 07:48:02 CST 2002


I use the code below to detect for IE and NS (other browsers basically).
I've noticed that NS and other browsers are fairly similar in how they show
font sizes etc - and if Opera give an IE header it still works well - same
for other browsers.

Note: I'd normally have this code in a Config.asp file at the top of each
page.
<%
userAgent = Request.ServerVariables( "HTTP_USER_AGENT" )
IF INSTR( userAgent, "MSIE" ) > 0 THEN
FontSize = "11px"
Else
FontSize = "12px"
End If
%>

I'd the include a file that contains the stylesheet:
Ie <!--#include file="includes/StyleMe.htm"-->

In the include you would have:

<style type="text/css">
<!--
td.txt{
	font-family:verdana;
	font-size:<%=FontSize%>;
	color:#000000;
}
//-->
</style>

Therefore only having one stylesheet which is configurable through the
Config.asp file.

You could extend the browser detection for every browser if you so wish by
doing loads of If and Else statements - but i find the Ie detection works
fine.

Cheers

Paul

-----Original Message-----

> I was suggesting something like:
>
> if (document.all) {
> document.write('<link rel="stylesheet" href="/styles/ie.css"
> type="text/css" />');
> }
> else if (document.layers) {
>    document.write('<link rel="stylesheet" href="/styles/ns4.css"
> type="text/css" />');
> }

Bad Bad bad!
Mozilla/ Netscape 6 don't use neither document.all (IE proprietary) nor
document.layers (Netscape 4.x proprietary), so you end up not missing one of
the browsers that supports CSS layouts the best....
For a better approach, see:
http://mozilla-evangelism.bclary.com/fep/

Regards,
Shoshannah Forbes
http://www.forbes.co.il


--
For unsubscribe and other options, including
the Tip Harvester and archive of thelist go to:
http://lists.evolt.org Workers of the Web, evolt !




More information about the thelist mailing list