SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict Knightime's Avatar
    Join Date
    Jan 2003
    Location
    USA
    Posts
    376
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Browser Specific Work-around

    I found something that might be useful to some people. I notice that some people are concerned with ensuring their pages are viewed as intended on various browsers. This is probably not a bad idea as it shows dedication and the desire to make things work more completely. Validating to the latest standards is also a good idea. I don't put a page up until it validates xhtml 1.1

    The following might take a bit to set up, but once done, I believe designers can establish a new set of templates for themselves. I am sure something like this is located on the forum already, but I still read a lot about "browser issues" so maybe it warrents a relook.

    </preface>
    <meatandpotatos>

    One way to get around all the browser compatibility issues is to use a different style sheet for each browser. You can do this by adding a JavaScript block such as the one below to the <head> section of your HTML document(s):

    <script language="JavaScript">
    <!--
    if(-1 != navigator.userAgent.indexOf("MSIE"))
    {
    // Internet Explorer
    document.write('<link rel="stylesheet" type="text/css" href="ie.css">');
    }
    else if (-1 != navigator.userAgent.indexOf("Mozilla"))
    {
    // Netscape
    document.write('<link rel="stylesheet" type="text/css" href="netscape.css">');
    }
    else
    {
    // other
    document.write('<link rel="stylesheet" type="text/css" href="other.css">');
    }
    //-->
    </script>

  2. #2
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Might be useful...





    ...but is this what we want to do, use a different style sheet for each browser?
    My policy is; ignore non-standard browsers

  3. #3
    SitePoint Addict Knightime's Avatar
    Join Date
    Jan 2003
    Location
    USA
    Posts
    376
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That is certainly valid.

    The script is a valid option if you wish to find a more organized way too make your site display consistantly across various browsers.

    It all depends on what the designer wishes to accomplish.

    Validate to the most current standard
    Make site display as intended on every browser possible
    Make site display on only a couple of current browsers
    Don't care if anyone ever see's my site, it's for me only!!!


    There are different ways to accomplish just about anything with markup languages. There are the hard ways, easy ways, work-around ways, hack ways, compliant ways. The javascript posted above offers a possible compliant method that certainly seems like a well thought-out and organized option. For the meantime, it might be useful while consistant standards and universal browser architectures are being developed and scripts like this aren't necessary. Seeing as how it was impossible to predict that standards would be so complex for markup languages, it's not that unreasonable to implement workable and solid solutions until we live in a perfectly wide web world

    </lecture>

  4. #4
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've used that code before. I like it too
    Content Writing Service - Get custom SEO articles for 10$

  5. #5
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,350
    Mentioned
    179 Post(s)
    Tagged
    6 Thread(s)
    Hi,

    While I think it's a good idea to make your site as compatible as possible, in your example won't you end up with loads of stylesheets. I believe there are over 50 different browsers out there.

    It isn't just different browsers you need to accomodate its each different version of each browser that is different also. e.g.IE5 has a completely broken box model whereas IE6's box model is more or less ok.

    Also you could argue that using javascript is less compatible as I believe that at the last count 15% of users have javascript turned off. Which means that you would loose more users than if you just code for IE5 & 6 .So you will also need to set up a default stylesheet anyway.

    I don't know what the answer is but I do feel that we should be programming for the future and not the past. If your site is programmed to standards then eventually (with any luck) all new browsers will be equal and pages will start to look the way they were intended.

    Anyway I've borrowed your script in case I'm wrong

    Paul


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •