Skip to content

Web2Coder

My Desktop Blog News Articles Tutorials Links Forum
You are here: Home arrow Blog arrow Browsers And CSS
Browsers And CSS Print E-mail
Written by Administrator   
Sunday, 18 February 2007
Tag it:
Stumble
Delicious
Digg
feedmelinks
Reddit
YahooMyWeb
Spurl
Technorati

Have you ever designed a website that shows up itself differently in various browsers? Here I have some solutions for this. Using a java script for detecting browsers, you can easily define various CSS style sheets for different browsers.

I had the same problem with the template I designed that unfortunately I couldn’t solve this problem unless I found a real helpful java script for solving this problem. Using this script is so easy and it is well documented, so you would probably understand how to work with it.
Unfortunately if you check statistics of websites you would figure out that the majority of online users work with Internet Explorer. And the majority of these users work with IE 6. Since IE6 is the default browser available in each windows XP operating system, people are more willing to use this browser rather than the other. So it is important to define various style sheets for different browsers.

Click here to Download the JS code. or click on the link below

javascript_browser_detection.zip

The only thing that you should consider is to put this script in your webpage <head> </head> part and change the css file names.

Example:

<script type = "text/javascript" src = "http://www.yourwebsite.com/js/javascript_browser_detection.js"> </script>
<script type = "text/javascript">
d = document;
    if ( ie5 ) {
        d.write('<link rel = "stylesheet" type = "text\/css" href = "http://www.yourwebsite.com/css/ie6.css" />');
    }
    else if ( document.layers ){
        d.write('<link rel = "stylesheet" type = "text\/css" href = "http://www.yourwebsite.com/css/ie6.css" />');
    }
    else if ( ie6 ){
        d.write('<link rel = "stylesheet" type = "text\/css" href = "http://www.yourwebsite.com/css/ie6.css" />');
    }
    else if ( ie7 ){
        d.write('<link rel = "stylesheet" type = "text\/css" href = "http://www.yourwebsite.com/css/ie7.css" />');
    }
    else if ( moz && ( nu < 1 ) ){
        d.write('<link rel = "stylesheet" type = "text\/css" href = "http://www.yourwebsite.com/css/moz.css" />');
    }
    else {
        d.write('<link rel = "stylesheet" type = "text\/css" href = "http://www.yourwebsite.com/css/ie7.css" />');
    }
</script>

Trackback(0)
Comments (3)Add Comment
It's nice to know
written by Adaptiv Media, January 26, 2008
It's nice to be given a few options to combat the problem of having to use css hacks because some browsers just don't like being helpful. PHP also works out as a good solution for creating synchronised cross-browser designed websites. Try searching G for this so you can weigh up your options. Thanks for the share!
Disagree
written by Damoon Rashidi, February 13, 2008
I have to say that I disagree with this technique. I know that it is wildly used, however It's not standards compliant. A web developer should not have to change their website that works fine in Firefox or Safari (the two most standards compliant browsers) to make it work in IE 5-7. People should put pressure on IE to actually make a css parsing engine that works (which they have, and it will be included in IEsmilies/cool.gif etc.

Just my two cents.
css text
written by ders örnek, June 23, 2008
CSS TEXT examples , Properties , Attribute -
http://css-lessons.ucoz.com/css-text-properties.htm

Write comment
quote
bold
italicize
underline
strike
url
image
quote
quote
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley

security code
Write the displayed characters


Copyright 2007. All Rights Reserved.
busy
Last Updated ( Monday, 19 February 2007 )
 
< Prev

Login


[+]
  • Narrow screen resolution
  • Wide screen resolution
  • Auto width resolution
  • Increase font size
  • Decrease font size
  • Default font size
  • fresh color
  • hot color
  • natural color
  • dark color