Skip to content

Instantly share code, notes, and snippets.

Created September 13, 2013 02:02
Show Gist options
  • Select an option

  • Save anonymous/6546078 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/6546078 to your computer and use it in GitHub Desktop.

Revisions

  1. @invalid-email-address Anonymous created this gist Sep 13, 2013.
    7 changes: 7 additions & 0 deletions An-Anonymous-Pen.markdown
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    An Anonymous Pen
    ----------------
    Uses a technique in which you could target any browser by User Agent string. Which should be way last resort.

    A [Pen](http://codepen.io/anon/pen/AEGvq) by [Captain Anonymous](http://codepen.io/anon) on [CodePen](http://codepen.io/).

    [License](http://codepen.io/anon/pen/AEGvq/license).
    1 change: 1 addition & 0 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    <h1>I'll be blue in IE 10 and black in everything else.</h1>
    5 changes: 5 additions & 0 deletions script.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    var b = document.documentElement;
    b.setAttribute('data-useragent', navigator.userAgent);
    b.setAttribute('data-platform', navigator.platform );

    // IE 10 == Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)
    8 changes: 8 additions & 0 deletions style.css
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    html[data-useragent*='MSIE 10.0'] h1 {
    color: blue;
    }

    h1 {
    text-align: center;
    padding: 20px;
    }