Forum Moderators: not2easy
My Question: Does anyone see any reason (beyond purist ones. I mean any practical reason) to avoid all those hacks? The Tan Hack is supposed to be pretty safe, effecting IE 5x Win and possibly IE mac 4x only, and forward compatible barring any unforseen proprietary moves by certaIn wEb browsers.
Any thoughts? I could, theoretically deconstruct the site and try a different approach, but I would, obviously, rather not.
Thanks in advance. I look forward to hearing what the 'panel' thinks.
This is what sites like the newly CSS designed macromedia.com do.
That way you don't have to have a stylesheet filled with hacks, you can have one for standards browsers, and one for IE 5x windows browsers. Less chance of coding errors, forgetting some line of code to neutralize the hacks, etc
What method would you use for the server-side script? ANd is there a language I can use that is similar enough to javascript (where most of my scripting experience lies) that I could learn it fast?
Something like this'll pick between browsers and insert style sheets accordingly:
<!--#if expr="$HTTP_USER_AGENT = /MSIE 6./" -->
<link rel="stylesheet" href="[b]IE_6_STYLE[/b]" type="text/css" />
<!--#elif expr="$HTTP_USER_AGENT = /MSIE 5./" -->
<link rel="stylesheet" href="[b]IE_5_STYLE[/b]" type="text/css" />
<!--#elif expr="$HTTP_USER_AGENT = /Gecko/" -->
<link rel="stylesheet" href="[b]MOZILLA_NETSCAPE_STYLE[/b]" type="text/css" />
<!--#else -->
<link rel="stylesheet" href="[b]COMPATIBLE_STYLE[/b]" type="text/css" />
<!--#endif -->
<link rel="stylesheet" href="[b]MOZILLA_NETSCAPE_STYLE[/b]" type="text/css" /> Obviously this can be made as complicated as you like, but that's the basic layout.
Nice huh?
J.
[edited by: j4mes at 7:48 pm (utc) on June 29, 2004]
*html YOURSELECTOR {
IE ONLY STYLE RULE
}
...any styles in it are not seen by non-ie browsers.
It's primarily used to fix the Box Model in IE 5.x, but IE has many other issues that the Tan Hack can fix, provided you don't mind bloating your CSS with them (as I have done).
<link rel="stylesheet" href="style.css" type="text/css" /> and then either change the extensions of your pages to ".shtml" (so your server parses them) or if you'd rather keep them as ".html" or ".htm" (I do) then add the following to your .htaccess file to make sure ".html"s and ".htm"s get parsed:
AddType text/x-server-parsed-html .html
AddType text/x-server-parsed-html .htm
J.
I'm assuming you're using a Linux server btw, in case it isn't working!
Suzy
But what happens if the browser happens to be Opera or Mozilla spoofing as IE
And a bunch of other possibilities, that test is not nearly robust enough for today's browsers, I'd either use the method suzyUK recommends if only IE Windows browsers need to be detected, which is fool proof, forward compatible, and not dependent on any outside methods, or find a real browser detection script on the web, there's a few good ones out there if you look.
The above SSI test could fail for Opera, Konqueror, Safari, any Gecko browser, and won't distinguish between the reasonably standards compliant IE 5x Mac browsers and the non standards compliant IE 5x windows browsers.