www.webdeveloper.com
Results 1 to 9 of 9

Thread: [Headache] JavaScript - CSS for each browser

  1. #1
    Join Date
    Aug 2013
    Posts
    57

    [Headache] JavaScript - CSS for each browser

    Hello

    I'm really getting pretty frustrated now, I've made a site who's almost ready, ready on Chrome.
    But of course there is need to be a pain in the ass, called: Microsoft Internet Explorer!

    How can I make my site look good on each browser?

    I tried:

    Code:
    [if IE]
    
    [end if IE]
    Pretty useless except if someone explains me 100% how it works.

    Code:
    if (Browser == IE)
    {
    
    }
    or something related, tried 5 different of those but yeah, guess what.

    The ultimate solution would be something like:

    Code:
    if (browser == 'Internet Explorer') {
    [
    //CSS for ie here
    ]
    }
    And that for all browsers.

    How does that exactly works?

    Thanks for reading,

    Niely

  2. #2
    Join Date
    Oct 2012
    Location
    /dev/null
    Posts
    15
    I feel your pain, makes me wish that chrome was the only browser around and let the web go forward, anyway here are examples for ie only fixes

    http://davidwalsh.name/ie-conditional-comments


    For mozilla fixes

    http://css-tricks.com/snippets/css/c...eting-firefox/

    Not that you only need to identify which css property is giving you problems and apply those conditionals
    Last edited by molossus; 12-17-2013 at 04:23 PM.

  3. #3
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,348
    Not a JavaScript problem, please direct your query to the CSS threads, you will get a better answer to your conditionals and CSS problem.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  4. #4
    Join Date
    Oct 2013
    Posts
    491
    Also, IE10+ does not recognize "conditional" statements. In fact, IE11 doesn't even identify itself as MSIE. A couple of examples:
    "Mozilla/5.0 (Windows NT 6.3; Win64; x64; Trident/7.0; Touch; MDDCJS; rv:11.0) like Gecko"
    "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"

    How MS can say that IE is "like Gecko" is a topic for another thread, but it shows to go that conditional statements don't apply. In fact, if you write a JavaScript that asks if the browser is "Internet Explorer" or "MSIE" it probably wouldn't pick up on those and default to whatever your non-IE CSS file is. Pulling "Trident" from the UserAgent string might be a start, but I'm not the guy to tell you how to do that.

  5. #5
    Join Date
    Aug 2013
    Posts
    57
    Hi!

    Thanks it worked for internet explorer! Awesome!

    But the Firefox solution
    @-moz-document url-prefix()

    Didn't work.

  6. #6
    Join Date
    Aug 2013
    Posts
    57
    And if I use those tags:

    [IF ie]>
    <![endif]

    My standard CSS doesn't work anymore.

  7. #7
    Join Date
    Dec 2013
    Posts
    1
    It is really annoying to use different CSS for each browser. If anyone knows how to solve this issue, then please tell me.

  8. #8
    Join Date
    Aug 2013
    Posts
    57
    Hi Cornis, I found a guide that fixes your problem!
    http://www.icode4u.tk/guides/adjust-...h-browser.html

  9. #9
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,348
    Like I said, not a JavaScript problem.

    I suggest you use a server-side method in determining the browser visiting your page and apply a CSS to the page being called, offering a fall back option of the browser can't be determined.

    You would need to account for mobile users as well, by that I don't mean the annoying way in whihc mobile users get forced in to using a mobile device styled web page as phones like mine have a web browser that is every bit as capable as a regular web browser, older phones don't offer much in way of support but... those types are not really designed to accessing web sites, merely accessing URL's for emailing to the users email address to view on regular PC.

    Anyway, JavaScript can't help you, its CSS forums or use a server-side like PHP.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles