PDA

View Full Version : Browser Ident Stylesheet Trick


FattyMembrane
Feb 29, 2004, 04:33 PM
i spent 3 hours yesterday trying to get the website (http://grove.ufl.edu/~fuf) for a club of which i'm a member to work properly in IE. The site rendered fine in mozilla/khtml but of course IE has serious css bugs and the page looked like crap. i ended up having to create a separate stylesheet for IE and after pilfering some code from various resources on the net, i came up with a little javascript that you can put in the <head> of your file that will give IE a special stylesheet. this is nothing groundbreaking, but i thought it might be helpful to those of you struggling to keep your site IE compliant.

<script type="text/javascript">
var ua = navigator.userAgent.toLowerCase();
this.isIE = (ua.indexOf('msie') != -1);

if (this.isIE)
{document.write("<link rel='stylesheet' type='text/css' href='iestylesheet.css' />");}
else
{document.write("<link rel='stylesheet' type='text/css' href='stylesheet.css' />");}
</script>

mnkeybsness
Feb 29, 2004, 04:42 PM
I have to load a javascript file to make Internet Explorer allow alpha transparency with PNG-24 images. Instead of having javascript to check if it is IE, you can use something with this style...
<!--[if gte IE 5.5000]>
<script type="text/javascript" src="http://www.yoursite.com/link-to-javascript"></script>
<![endif]-->

This works really well because it will just be read as a comment by any browser except IE 5.5+. You could also do something similar with CSS.

mrjamin
Feb 29, 2004, 05:18 PM
I have to load a javascript file to make Internet Explorer allow alpha transparency with PNG-24 images. Instead of having javascript to check if it is IE, you can use something with this style...
<!--[if gte IE 5.5000]>
<script type="text/javascript" src="http://www.yoursite.com/link-to-javascript"></script>
<![endif]-->

This works really well because it will just be read as a comment by any browser except IE 5.5+. You could also do something similar with CSS.

wow!! that's cool!