Alternative browser-based stylesheets

Does anyone know if it is possible for its javascript to determine which browser uses the page and load the stylesheet accordingly. Ideally, I would like to have a different sitlet for each browser, and css requests for media only now.

+3
source share
3 answers

If you are trying to use only versions of IE, conditional comments work just fine!

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

If you want to target browsers, there are Modernizr features:

http://www.modernizr.com/

If none of the above actions you find in the browser:

http://www.w3schools.com/js/js_browser.asp

+3
source

, . navigator ", , jQuery .

0

(: http://www.w3schools.com/js/js_browser.asp):

<div id="example"></div>

<script type="text/javascript">
  txt = "<p>Browser CodeName: " + navigator.appCodeName + "</p>";
  txt+= "<p>Browser Name: " + navigator.appName + "</p>";
  txt+= "<p>Browser Version: " + navigator.appVersion + "</p>";
  txt+= "<p>Cookies Enabled: " + navigator.cookieEnabled + "</p>";
  txt+= "<p>Platform: " + navigator.platform + "</p>";
  txt+= "<p>User-agent header: " + navigator.userAgent + "</p>";

  document.getElementById("example").innerHTML=txt;
</script>

, , CSS JavaScript:
CSS Javascript?

(: http://snippets.dzone.com/posts/show/4554):

function includeCSS(p_file) {
    var v_css  = document.createElement('link');
    v_css.rel = 'stylesheet'
    v_css.type = 'text/css';
    v_css.href = p_file;
    document.getElementsByTagName('head')[0].appendChild(v_css);
}
0

All Articles