Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

HTML

Conditional Comment gt IE7 AND other browsers

1
2
3
4
5
<!--[if gt IE 7]> <!-- -->
Here is some code for anything but IE 7 and below.
<!-- <![endif]-->

<!-- http://stackoverflow.com/questions/10159642/ie-conditional-comments-and-chrome-firefox -->
https://snipt.net/embed/db6ac18b031ce13a7ba94ee1d836a8a9/
https://snipt.net/raw/db6ac18b031ce13a7ba94ee1d836a8a9/
db6ac18b031ce13a7ba94ee1d836a8a9
html
HTML
5
2016-12-02T16:32:22
True
False
False
Sep 19, 2013 at 08:27 PM
/api/public/snipt/82064/
conditional-comment-gt-ie7-and-other-browsers
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c">&lt;!--[if gt IE 7]&gt; &lt;!-- --&gt;</span> </span><span id="L-2"><a name="L-2"></a>Here is some code for anything but IE 7 and below. </span><span id="L-3"><a name="L-3"></a><span class="c">&lt;!-- &lt;![endif]--&gt;</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a><span class="c">&lt;!-- http://stackoverflow.com/questions/10159642/ie-conditional-comments-and-chrome-firefox --&gt;</span> </span></pre></div> </td></tr></table>
"conditional comments", html, ie

JavaScript

IE friendly addEventListener

1
2
3
4
5
if (window.addEventListener) {
    
} else if (window.attachEvent) {

}
https://snipt.net/embed/25a59766ebbc55486598c5e1a7c025f8/
https://snipt.net/raw/25a59766ebbc55486598c5e1a7c025f8/
25a59766ebbc55486598c5e1a7c025f8
js
JavaScript
6
2016-12-02T10:08:16
True
False
False
/api/public/snipt/77414/
ie-friendly-addeventlistener
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="k">if</span> <span class="p">(</span><span class="nb">window</span><span class="p">.</span><span class="nx">addEventListener</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nb">window</span><span class="p">.</span><span class="nx">attachEvent</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
addEventListener, compatibility, ie, javascript, js

JavaScript

javascript: browser detection

1
2
3
4
5
6
7
// javascript: browser detection

var ie = function(){ return navigator.userAgent.indexOf('MSIE') != -1; }
var safari = function(){ return navigator.vendor != undefined && navigator.vendor.indexOf("Apple") != -1; }
var chrome = function(){ return navigator.vendor != undefined && navigator.vendor.indexOf('Google') != -1; }
var firefox = function(){ return (navigator.userAgent.indexOf('Mozilla') != -1 && navigator.vendor != undefined && navigator.vendor == ''); }
var windows = function(){ return navigator.platform == "Win32"; }
https://snipt.net/embed/da90c87c5420efbd4e3434532b703052/
https://snipt.net/raw/da90c87c5420efbd4e3434532b703052/
da90c87c5420efbd4e3434532b703052
js
JavaScript
7
2016-12-02T16:32:27
True
False
False
Sep 08, 2012 at 08:33 PM
/api/public/snipt/46917/
javascript-browser-detection
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c1">// javascript: browser detection</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="kd">var</span> <span class="nx">ie</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(){</span> <span class="k">return</span> <span class="nx">navigator</span><span class="p">.</span><span class="nx">userAgent</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="s1">&#39;MSIE&#39;</span><span class="p">)</span> <span class="o">!=</span> <span class="o">-</span><span class="mi">1</span><span class="p">;</span> <span class="p">}</span> </span><span id="L-4"><a name="L-4"></a><span class="kd">var</span> <span class="nx">safari</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(){</span> <span class="k">return</span> <span class="nx">navigator</span><span class="p">.</span><span class="nx">vendor</span> <span class="o">!=</span> <span class="kc">undefined</span> <span class="o">&amp;&amp;</span> <span class="nx">navigator</span><span class="p">.</span><span class="nx">vendor</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="s2">&quot;Apple&quot;</span><span class="p">)</span> <span class="o">!=</span> <span class="o">-</span><span class="mi">1</span><span class="p">;</span> <span class="p">}</span> </span><span id="L-5"><a name="L-5"></a><span class="kd">var</span> <span class="nx">chrome</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(){</span> <span class="k">return</span> <span class="nx">navigator</span><span class="p">.</span><span class="nx">vendor</span> <span class="o">!=</span> <span class="kc">undefined</span> <span class="o">&amp;&amp;</span> <span class="nx">navigator</span><span class="p">.</span><span class="nx">vendor</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="s1">&#39;Google&#39;</span><span class="p">)</span> <span class="o">!=</span> <span class="o">-</span><span class="mi">1</span><span class="p">;</span> <span class="p">}</span> </span><span id="L-6"><a name="L-6"></a><span class="kd">var</span> <span class="nx">firefox</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(){</span> <span class="k">return</span> <span class="p">(</span><span class="nx">navigator</span><span class="p">.</span><span class="nx">userAgent</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="s1">&#39;Mozilla&#39;</span><span class="p">)</span> <span class="o">!=</span> <span class="o">-</span><span class="mi">1</span> <span class="o">&amp;&amp;</span> <span class="nx">navigator</span><span class="p">.</span><span class="nx">vendor</span> <span class="o">!=</span> <span class="kc">undefined</span> <span class="o">&amp;&amp;</span> <span class="nx">navigator</span><span class="p">.</span><span class="nx">vendor</span> <span class="o">==</span> <span class="s1">&#39;&#39;</span><span class="p">);</span> <span class="p">}</span> </span><span id="L-7"><a name="L-7"></a><span class="kd">var</span> <span class="nx">windows</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(){</span> <span class="k">return</span> <span class="nx">navigator</span><span class="p">.</span><span class="nx">platform</span> <span class="o">==</span> <span class="s2">&quot;Win32&quot;</span><span class="p">;</span> <span class="p">}</span> </span></pre></div> </td></tr></table>
brower, detection, ie, javascript
Copyrighted, illegal, or inappropriate content? Email [email protected].