Results 1 to 2 of 2

Thread: javascript to switch style sheet?

  1. #1
    Join Date
    Mar 2008
    Location
    Iowa
    Posts
    103

    javascript to switch style sheet?

    Due to browser differences, positioning of some divs in my site differ in IE and FF. I don't think there's a way to fix this, so is a there a way to use javascript to switch the external style sheet depending on the detected browser?

  2. #2
    Join Date
    Feb 2006
    Location
    Salisbury UK
    Posts
    4,332
    You can use javascript to use a different stylesheet but it's more complicated than using a conditional comment.

    You should get your page working properly in Firefox first as that is probably the most standards-compliant browser. Then use a conditional comment in the head section with different styles for IE6 or IE7. These don't use javascript.

    See http://www.wickham43.supanet.com/tut...tionalcomments

    You can also use a completely different stylesheet for IE browsers using the above method if you have lots of different styles to edit or if you want a completely different color scheme, but it can only distinguish between any IE browser and the others, not between say Opera and Safari.

    If you want to use javascript, look at
    http://webdesign.about.com/library/weekly/aa123101a.htm
    and
    http://webdesign.about.com/library/weekly/aa123101b.htm
    (it's a bit ut of date and I haven't tried it. You can use the same method for IE6 and IE7).
    Code downloaded to my PC will be deleted in due course.
    WIN7; IE9, Firefox, Opera, Chrome and Safari for Windows; screen resolution usually 1366*768.
    Also IE6 on W98 with 800*600 and IE8 on Vista 1440*900.

Similar Threads

  1. CSS Style Sheet Help
    By MaX ReaLiTy in forum Web Design, HTML Reference and CSS
    Replies: 1
    Last Post: 09 Nov 2005, 07:08 PM
  2. Is it possible to have an editable side navbar in an external style sheet?
    By djdel002 in forum Web Design, HTML Reference and CSS
    Replies: 1
    Last Post: 01 Aug 2005, 10:06 AM

Posting Permissions

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