Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Sep 2005
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Ccontrol content/stylsheet ref based on Browser

    I am having some issues resolving Microsoft and "The Rest of The World" differences. There are quite a few...
    Is there a way to ref different stylesheets based on the output from navigator.appName?
    How far can I go in referencing different files for output stricly with client-side JavaScript? Maybe display completely different content depending on the browser?
    This may be simple or impossible; all of my Java exp. is from hacking someone else's code and making changes as to suit evolving needs.
    I am alos looking for a comprehensive reference on the web if anyone can point me. Books (in english) on Java are hard to comeby up here in the northern hills of Thailand.
    While doing this with Perl, PHP or other server-side solutions is relatively simple, I am stuck with no server-side help for a next few months.

    Any help is mch appreciated

    FF

  • #2
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    It's not much of an answer, but would this be any help?

    http://www.quirksmode.org/css/condcom.html

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,462
    Thanks
    0
    Thanked 633 Times in 623 Posts
    You can't use navigator.appName to determine which browser someone is using because a lot of people using other browsers have it set to report itself as IE when it is asked.

    The better way is to actually test if a particular feature is supported by the given browser before using it. That way it doesn't matter what the browser claims to be.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #4
    New Coder
    Join Date
    Sep 2005
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Spudhead
    It's not much of an answer, but would this be any help?

    http://www.quirksmode.org/css/condcom.html
    let's see if
    <!--[if IE]>
    <link rel="stylesheet" href="style/msie.css" type="text/css"/>
    <!--[endif]-->>
    works...
    Yes and no. It links to the new style page. Also displays the <!--[endif]-->
    in my page bears some tweaking. There are other issues in the way IE handles the rest of the code.
    However, it does give me some options and I will certainly use it in the future, with some tweaks to the parent code I could make this work. For now, I'm redirecting to two different pages based on what the browser reports its name as.

    Quote Originally Posted by felgall
    The better way is to actually test if a particular feature is supported by the given browser before using it. That way it doesn't matter what the browser claims to be
    Thanks for that. So now all I have to figure out is how to ask the browser if parses XML, XHTML & CSS2 according to the W3C strict DTDs. I'm sure I'll figure it out. Be fun figuring it out; for now, in production, I'll let;

    if(msie or wannabe_msie)
    {
    just load an msie page and forget it
    }else{
    load the real page
    }


    handle the issues.
    My page works fine in Lynx and Links, so just going to have to code to a new lowest common denominator. I am just finding too many style/parse discrepencies to poll for each one.
    Biggest problem?
    Having to work in Windoze!!!
    All day!
    Gonna have to try IE for Unix on my slackware machine.


  •  

    Posting Permissions

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