snipt

Ctrl+h for KB shortcuts

JavaScript

Create array with lines from a textarea

var myArray = formName.textareaName.val.split("\n");
https://snipt.net/embed/db5e52ff8de445031dd8e8dbd0a927ba/
/raw/db5e52ff8de445031dd8e8dbd0a927ba/
db5e52ff8de445031dd8e8dbd0a927ba
js
JavaScript
1
2019-07-17T04:23:57
True
False
False
/api/public/snipt/6700/
create-array-with-lines-from-a-textarea
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="kd">var</span> <span class="nx">myArray</span> <span class="o">=</span> <span class="nx">formName</span><span class="p">.</span><span class="nx">textareaName</span><span class="p">.</span><span class="nx">val</span><span class="p">.</span><span class="nx">split</span><span class="p">(</span><span class="s2">&quot;\n&quot;</span><span class="p">);</span> </span></pre></div> </td></tr></table>
array, split, textarea

JavaScript

wtframework

javascript:(function(){el=document.getElementById(%22__wtframework%22);if(el){document.body.removeChild(el);return%20}var%20c=document.createElement(%22a%22);c.id=%22__wtframework%22;c.style.opacity=%220.7%22;c.style.filter=%22alpha(opacity=70)%22;c.style.position=%22fixed%22;c.style.zIndex=%229000%22;c.style.top=%2215px%22;c.style.right=%2220px%22;c.style.background=%22#000%22;c.style.styleFloat=%22right%22;c.style.padding=%227px%2010px%22;c.style.color=%22%23fff%22;c.style.border=%22solid%202px%20%23fff%22;c.style.textDecoration=%22none%22;c.style.textAlign=%22left%22;c.style.font=%2212px%20Lucida%20Grande,Helvetica,Tahoma%22;c.style.MozBorderRadius=%225px%22;c.style.WebkitBorderRadius=%225px%22;c.style.WebkitBoxShadow=%220px%200px%2020px%20%23000%22;c.style.MozBoxShadow=%220px%200px%2020px%20%23000%22;c.href=%22javascript:void(0)%22;document.body.appendChild(c);c.onclick=function(){document.body.removeChild(c)};var%20fm=%22Bummer...%20Try%20checking%20the%20source%20code%22;try{fm=(MooTools?%22MooTools%20(%22+MooTools.version+%22)%22:false)}catch(d){}try{fm=(YAHOO?%22YUI%20(%22+YAHOO.util.Dom.VERSION+%22)%22:false)}catch(d){}try{fm=%22Prototype%20(%22+Prototype.Version+%22)%22}catch(d){}try{fm+=%22%3Cbr/%3E%20Script.aculo.us%20(%22+Scriptaculous.Version+%22)%22}catch(d){}try{fm=(jQuery?%22jQuery%20(%22+jQuery.fn.jquery+%22)%22:false)}catch(d){}try{fm=(dojo?%22Dojo%20Toolkit%20(%22+dojo.version+%22)%22:false)}catch(d){}try{fm=(MochiKit?%22MochiKit%20(%22+MochiKit.MochiKit.VERSION+%22)%22:false)}catch(d){}try{fm=(base2?%22Base2%20(%22+base2.version+%22)%22:false)}catch(d){}c.innerHTML=unescape(fm.toString())})();
https://snipt.net/embed/a60ea19cb845f80853a37b74705e0f01/
/raw/a60ea19cb845f80853a37b74705e0f01/
a60ea19cb845f80853a37b74705e0f01
js
JavaScript
1
2019-07-16T19:43:00
True
False
False
/api/public/snipt/6661/
wtframework
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="nx">javascript</span><span class="o">:</span><span class="p">(</span><span class="kd">function</span><span class="p">(){</span><span class="nx">el</span><span class="o">=</span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="o">%</span><span class="mi">22</span><span class="nx">__wtframework</span><span class="o">%</span><span class="mi">22</span><span class="p">);</span><span class="k">if</span><span class="p">(</span><span class="nx">el</span><span class="p">){</span><span class="nb">document</span><span class="p">.</span><span class="nx">body</span><span class="p">.</span><span class="nx">removeChild</span><span class="p">(</span><span class="nx">el</span><span class="p">);</span><span class="k">return</span><span class="o">%</span><span class="mi">20</span><span class="p">}</span><span class="kd">var</span><span class="o">%</span><span class="mi">20</span><span class="nx">c</span><span class="o">=</span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="o">%</span><span class="mi">22</span><span class="nx">a</span><span class="o">%</span><span class="mi">22</span><span class="p">);</span><span class="nx">c</span><span class="p">.</span><span class="nx">id</span><span class="o">=%</span><span class="mi">22</span><span class="nx">__wtframework</span><span class="o">%</span><span class="mi">22</span><span class="p">;</span><span class="nx">c</span><span class="p">.</span><span class="nx">style</span><span class="p">.</span><span class="nx">opacity</span><span class="o">=%</span><span class="mf">220.7</span><span class="o">%</span><span class="mi">22</span><span class="p">;</span><span class="nx">c</span><span class="p">.</span><span class="nx">style</span><span class="p">.</span><span class="nx">filter</span><span class="o">=%</span><span class="mi">22</span><span class="nx">alpha</span><span class="p">(</span><span class="nx">opacity</span><span class="o">=</span><span class="mi">70</span><span class="p">)</span><span class="o">%</span><span class="mi">22</span><span class="p">;</span><span class="nx">c</span><span class="p">.</span><span class="nx">style</span><span class="p">.</span><span class="nx">position</span><span class="o">=%</span><span class="mi">22</span><span class="nx">fixed</span><span class="o">%</span><span class="mi">22</span><span class="p">;</span><span class="nx">c</span><span class="p">.</span><span class="nx">style</span><span class="p">.</span><span class="nx">zIndex</span><span class="o">=%</span><span class="mi">229000</span><span class="o">%</span><span class="mi">22</span><span class="p">;</span><span class="nx">c</span><span class="p">.</span><span class="nx">style</span><span class="p">.</span><span class="nx">top</span><span class="o">=%</span><span class="mi">2215</span><span class="nx">px</span><span class="o">%</span><span class="mi">22</span><span class="p">;</span><span class="nx">c</span><span class="p">.</span><span class="nx">style</span><span class="p">.</span><span class="nx">right</span><span class="o">=%</span><span class="mi">2220</span><span class="nx">px</span><span class="o">%</span><span class="mi">22</span><span class="p">;</span><span class="nx">c</span><span class="p">.</span><span class="nx">style</span><span class="p">.</span><span class="nx">background</span><span class="o">=%</span><span class="mi">22</span><span class="err">#</span><span class="mi">000</span><span class="o">%</span><span class="mi">22</span><span class="p">;</span><span class="nx">c</span><span class="p">.</span><span class="nx">style</span><span class="p">.</span><span class="nx">styleFloat</span><span class="o">=%</span><span class="mi">22</span><span class="nx">right</span><span class="o">%</span><span class="mi">22</span><span class="p">;</span><span class="nx">c</span><span class="p">.</span><span class="nx">style</span><span class="p">.</span><span class="nx">padding</span><span class="o">=%</span><span class="mi">227</span><span class="nx">px</span><span class="o">%</span><span class="mi">2010</span><span class="nx">px</span><span class="o">%</span><span class="mi">22</span><span class="p">;</span><span class="nx">c</span><span class="p">.</span><span class="nx">style</span><span class="p">.</span><span class="nx">color</span><span class="o">=%</span><span class="mi">22</span><span class="o">%</span><span class="mi">23</span><span class="nx">fff</span><span class="o">%</span><span class="mi">22</span><span class="p">;</span><span class="nx">c</span><span class="p">.</span><span class="nx">style</span><span class="p">.</span><span class="nx">border</span><span class="o">=%</span><span class="mi">22</span><span class="nx">solid</span><span class="o">%</span><span class="mi">202</span><span class="nx">px</span><span class="o">%</span><span class="mi">20</span><span class="o">%</span><span class="mi">23</span><span class="nx">fff</span><span class="o">%</span><span class="mi">22</span><span class="p">;</span><span class="nx">c</span><span class="p">.</span><span class="nx">style</span><span class="p">.</span><span class="nx">textDecoration</span><span class="o">=%</span><span class="mi">22</span><span class="nx">none</span><span class="o">%</span><span class="mi">22</span><span class="p">;</span><span class="nx">c</span><span class="p">.</span><span class="nx">style</span><span class="p">.</span><span class="nx">textAlign</span><span class="o">=%</span><span class="mi">22</span><span class="nx">left</span><span class="o">%</span><span class="mi">22</span><span class="p">;</span><span class="nx">c</span><span class="p">.</span><span class="nx">style</span><span class="p">.</span><span class="nx">font</span><span class="o">=%</span><span class="mi">2212</span><span class="nx">px</span><span class="o">%</span><span class="mi">20</span><span class="nx">Lucida</span><span class="o">%</span><span class="mi">20</span><span class="nx">Grande</span><span class="p">,</span><span class="nx">Helvetica</span><span class="p">,</span><span class="nx">Tahoma</span><span class="o">%</span><span class="mi">22</span><span class="p">;</span><span class="nx">c</span><span class="p">.</span><span class="nx">style</span><span class="p">.</span><span class="nx">MozBorderRadius</span><span class="o">=%</span><span class="mi">225</span><span class="nx">px</span><span class="o">%</span><span class="mi">22</span><span class="p">;</span><span class="nx">c</span><span class="p">.</span><span class="nx">style</span><span class="p">.</span><span class="nx">WebkitBorderRadius</span><span class="o">=%</span><span class="mi">225</span><span class="nx">px</span><span class="o">%</span><span class="mi">22</span><span class="p">;</span><span class="nx">c</span><span class="p">.</span><span class="nx">style</span><span class="p">.</span><span class="nx">WebkitBoxShadow</span><span class="o">=%</span><span class="mi">220</span><span class="nx">px</span><span class="o">%</span><span class="mi">200</span><span class="nx">px</span><span class="o">%</span><span class="mi">2020</span><span class="nx">px</span><span class="o">%</span><span class="mi">20</span><span class="o">%</span><span class="mi">23000</span><span class="o">%</span><span class="mi">22</span><span class="p">;</span><span class="nx">c</span><span class="p">.</span><span class="nx">style</span><span class="p">.</span><span class="nx">MozBoxShadow</span><span class="o">=%</span><span class="mi">220</span><span class="nx">px</span><span class="o">%</span><span class="mi">200</span><span class="nx">px</span><span class="o">%</span><span class="mi">2020</span><span class="nx">px</span><span class="o">%</span><span class="mi">20</span><span class="o">%</span><span class="mi">23000</span><span class="o">%</span><span class="mi">22</span><span class="p">;</span><span class="nx">c</span><span class="p">.</span><span class="nx">href</span><span class="o">=%</span><span class="mi">22</span><span class="nx">javascript</span><span class="o">:</span><span class="k">void</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span><span class="o">%</span><span class="mi">22</span><span class="p">;</span><span class="nb">document</span><span class="p">.</span><span class="nx">body</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">c</span><span class="p">);</span><span class="nx">c</span><span class="p">.</span><span class="nx">onclick</span><span class="o">=</span><span class="kd">function</span><span class="p">(){</span><span class="nb">document</span><span class="p">.</span><span class="nx">body</span><span class="p">.</span><span class="nx">removeChild</span><span class="p">(</span><span class="nx">c</span><span class="p">)};</span><span class="kd">var</span><span class="o">%</span><span class="mi">20</span><span class="nx">fm</span><span class="o">=%</span><span class="mi">22</span><span class="nx">Bummer</span><span class="p">...</span><span class="o">%</span><span class="mi">20</span><span class="nx">Try</span><span class="o">%</span><span class="mi">20</span><span class="nx">checking</span><span class="o">%</span><span class="mi">20</span><span class="nx">the</span><span class="o">%</span><span class="mi">20</span><span class="nx">source</span><span class="o">%</span><span class="mi">20</span><span class="nx">code</span><span class="o">%</span><span class="mi">22</span><span class="p">;</span><span class="k">try</span><span class="p">{</span><span class="nx">fm</span><span class="o">=</span><span class="p">(</span><span class="nx">MooTools</span><span class="o">?%</span><span class="mi">22</span><span class="nx">MooTools</span><span class="o">%</span><span class="mi">20</span><span class="p">(</span><span class="o">%</span><span class="mi">22</span><span class="o">+</span><span class="nx">MooTools</span><span class="p">.</span><span class="nx">version</span><span class="o">+%</span><span class="mi">22</span><span class="p">)</span><span class="o">%</span><span class="mi">22</span><span class="o">:</span><span class="kc">false</span><span class="p">)}</span><span class="k">catch</span><span class="p">(</span><span class="nx">d</span><span class="p">){}</span><span class="k">try</span><span class="p">{</span><span class="nx">fm</span><span class="o">=</span><span class="p">(</span><span class="nx">YAHOO</span><span class="o">?%</span><span class="mi">22</span><span class="nx">YUI</span><span class="o">%</span><span class="mi">20</span><span class="p">(</span><span class="o">%</span><span class="mi">22</span><span class="o">+</span><span class="nx">YAHOO</span><span class="p">.</span><span class="nx">util</span><span class="p">.</span><span class="nx">Dom</span><span class="p">.</span><span class="nx">VERSION</span><span class="o">+%</span><span class="mi">22</span><span class="p">)</span><span class="o">%</span><span class="mi">22</span><span class="o">:</span><span class="kc">false</span><span class="p">)}</span><span class="k">catch</span><span class="p">(</span><span class="nx">d</span><span class="p">){}</span><span class="k">try</span><span class="p">{</span><span class="nx">fm</span><span class="o">=%</span><span class="mi">22</span><span class="nx">Prototype</span><span class="o">%</span><span class="mi">20</span><span class="p">(</span><span class="o">%</span><span class="mi">22</span><span class="o">+</span><span class="nx">Prototype</span><span class="p">.</span><span class="nx">Version</span><span class="o">+%</span><span class="mi">22</span><span class="p">)</span><span class="o">%</span><span class="mi">22</span><span class="p">}</span><span class="k">catch</span><span class="p">(</span><span class="nx">d</span><span class="p">){}</span><span class="k">try</span><span class="p">{</span><span class="nx">fm</span><span class="o">+=%</span><span class="mi">22</span><span class="o">%</span><span class="mi">3</span><span class="nx">Cbr</span><span class="o">/%</span><span class="mi">3</span><span class="nx">E</span><span class="o">%</span><span class="mi">20</span><span class="nx">Script</span><span class="p">.</span><span class="nx">aculo</span><span class="p">.</span><span class="nx">us</span><span class="o">%</span><span class="mi">20</span><span class="p">(</span><span class="o">%</span><span class="mi">22</span><span class="o">+</span><span class="nx">Scriptaculous</span><span class="p">.</span><span class="nx">Version</span><span class="o">+%</span><span class="mi">22</span><span class="p">)</span><span class="o">%</span><span class="mi">22</span><span class="p">}</span><span class="k">catch</span><span class="p">(</span><span class="nx">d</span><span class="p">){}</span><span class="k">try</span><span class="p">{</span><span class="nx">fm</span><span class="o">=</span><span class="p">(</span><span class="nx">jQuery</span><span class="o">?%</span><span class="mi">22</span><span class="nx">jQuery</span><span class="o">%</span><span class="mi">20</span><span class="p">(</span><span class="o">%</span><span class="mi">22</span><span class="o">+</span><span class="nx">jQuery</span><span class="p">.</span><span class="nx">fn</span><span class="p">.</span><span class="nx">jquery</span><span class="o">+%</span><span class="mi">22</span><span class="p">)</span><span class="o">%</span><span class="mi">22</span><span class="o">:</span><span class="kc">false</span><span class="p">)}</span><span class="k">catch</span><span class="p">(</span><span class="nx">d</span><span class="p">){}</span><span class="k">try</span><span class="p">{</span><span class="nx">fm</span><span class="o">=</span><span class="p">(</span><span class="nx">dojo</span><span class="o">?%</span><span class="mi">22</span><span class="nx">Dojo</span><span class="o">%</span><span class="mi">20</span><span class="nx">Toolkit</span><span class="o">%</span><span class="mi">20</span><span class="p">(</span><span class="o">%</span><span class="mi">22</span><span class="o">+</span><span class="nx">dojo</span><span class="p">.</span><span class="nx">version</span><span class="o">+%</span><span class="mi">22</span><span class="p">)</span><span class="o">%</span><span class="mi">22</span><span class="o">:</span><span class="kc">false</span><span class="p">)}</span><span class="k">catch</span><span class="p">(</span><span class="nx">d</span><span class="p">){}</span><span class="k">try</span><span class="p">{</span><span class="nx">fm</span><span class="o">=</span><span class="p">(</span><span class="nx">MochiKit</span><span class="o">?%</span><span class="mi">22</span><span class="nx">MochiKit</span><span class="o">%</span><span class="mi">20</span><span class="p">(</span><span class="o">%</span><span class="mi">22</span><span class="o">+</span><span class="nx">MochiKit</span><span class="p">.</span><span class="nx">MochiKit</span><span class="p">.</span><span class="nx">VERSION</span><span class="o">+%</span><span class="mi">22</span><span class="p">)</span><span class="o">%</span><span class="mi">22</span><span class="o">:</span><span class="kc">false</span><span class="p">)}</span><span class="k">catch</span><span class="p">(</span><span class="nx">d</span><span class="p">){}</span><span class="k">try</span><span class="p">{</span><span class="nx">fm</span><span class="o">=</span><span class="p">(</span><span class="nx">base2</span><span class="o">?%</span><span class="mi">22</span><span class="nx">Base2</span><span class="o">%</span><span class="mi">20</span><span class="p">(</span><span class="o">%</span><span class="mi">22</span><span class="o">+</span><span class="nx">base2</span><span class="p">.</span><span class="nx">version</span><span class="o">+%</span><span class="mi">22</span><span class="p">)</span><span class="o">%</span><span class="mi">22</span><span class="o">:</span><span class="kc">false</span><span class="p">)}</span><span class="k">catch</span><span class="p">(</span><span class="nx">d</span><span class="p">){}</span><span class="nx">c</span><span class="p">.</span><span class="nx">innerHTML</span><span class="o">=</span><span class="nx">unescape</span><span class="p">(</span><span class="nx">fm</span><span class="p">.</span><span class="nx">toString</span><span class="p">())})();</span> </span></pre></div> </td></tr></table>
bookmarklet

JavaScript

ReCSS

javascript:void(function(){var%20i,a,s;a=document.getElementsByTagName('link');for(i=0;i%3Ca.length;i++){s=a[i];if(s.rel.toLowerCase().indexOf('stylesheet')%3E=0&&s.href)%20{var%20h=s.href.replace(/(&|%5C?)forceReload=\d+/,'');s.href=h+(h.indexOf('?')%3E=0?'&':'?')+'forceReload='+(new%20Date().valueOf())}}})();
https://snipt.net/embed/220b4aced822295fcc01aabcc57f7eed/
/raw/220b4aced822295fcc01aabcc57f7eed/
220b4aced822295fcc01aabcc57f7eed
js
JavaScript
2
2019-07-12T04:05:47
True
False
False
/api/public/snipt/6660/
recss
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="nx">javascript</span><span class="o">:</span><span class="k">void</span><span class="p">(</span><span class="kd">function</span><span class="p">(){</span><span class="kd">var</span><span class="o">%</span><span class="mi">20</span><span class="nx">i</span><span class="p">,</span><span class="nx">a</span><span class="p">,</span><span class="nx">s</span><span class="p">;</span><span class="nx">a</span><span class="o">=</span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementsByTagName</span><span class="p">(</span><span class="s1">&#39;link&#39;</span><span class="p">);</span><span class="k">for</span><span class="p">(</span><span class="nx">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span><span class="nx">i</span><span class="o">%</span><span class="mi">3</span><span class="nx">Ca</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span><span class="nx">i</span><span class="o">++</span><span class="p">){</span><span class="nx">s</span><span class="o">=</span><span class="nx">a</span><span class="p">[</span><span class="nx">i</span><span class="p">];</span><span class="k">if</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">rel</span><span class="p">.</span><span class="nx">toLowerCase</span><span class="p">().</span><span class="nx">indexOf</span><span class="p">(</span><span class="s1">&#39;stylesheet&#39;</span><span class="p">)</span><span class="o">%</span><span class="mi">3</span><span class="nx">E</span><span class="o">=</span><span class="mi">0</span><span class="o">&amp;&amp;</span><span class="nx">s</span><span class="p">.</span><span class="nx">href</span><span class="p">)</span><span class="o">%</span><span class="mi">20</span><span class="p">{</span><span class="kd">var</span><span class="o">%</span><span class="mi">20</span><span class="nx">h</span><span class="o">=</span><span class="nx">s</span><span class="p">.</span><span class="nx">href</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/(&amp;|%5C?)forceReload=\d+/</span><span class="p">,</span><span class="s1">&#39;&#39;</span><span class="p">);</span><span class="nx">s</span><span class="p">.</span><span class="nx">href</span><span class="o">=</span><span class="nx">h</span><span class="o">+</span><span class="p">(</span><span class="nx">h</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="s1">&#39;?&#39;</span><span class="p">)</span><span class="o">%</span><span class="mi">3</span><span class="nx">E</span><span class="o">=</span><span class="mi">0</span><span class="o">?</span><span class="s1">&#39;&amp;&#39;</span><span class="o">:</span><span class="s1">&#39;?&#39;</span><span class="p">)</span><span class="o">+</span><span class="s1">&#39;forceReload=&#39;</span><span class="o">+</span><span class="p">(</span><span class="k">new</span><span class="o">%</span><span class="mi">20</span><span class="nb">Date</span><span class="p">().</span><span class="nx">valueOf</span><span class="p">())}}})();</span> </span></pre></div> </td></tr></table>
bookmarklet

JavaScript

show content based on date

1
2
3
4
5
6
<script type="text/javascript">
	var myDate=new Date();
	myDate.setFullYear(2009,5,7);
	var today = new Date();
	if (today>myDate){document.getElementById('hidden').style.display = 'none';}
</script>
https://snipt.net/embed/782b5aa9783653194215d470f5078eee/
/raw/782b5aa9783653194215d470f5078eee/
782b5aa9783653194215d470f5078eee
js
JavaScript
6
2019-07-19T03:48:58
True
False
False
/api/public/snipt/6296/
show-content-based-on-date
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="o">&lt;</span><span class="nx">script</span> <span class="nx">type</span><span class="o">=</span><span class="s2">&quot;text/javascript&quot;</span><span class="o">&gt;</span> </span><span id="L-2"><a name="L-2"></a> <span class="kd">var</span> <span class="nx">myDate</span><span class="o">=</span><span class="k">new</span> <span class="nb">Date</span><span class="p">();</span> </span><span id="L-3"><a name="L-3"></a> <span class="nx">myDate</span><span class="p">.</span><span class="nx">setFullYear</span><span class="p">(</span><span class="mi">2009</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="mi">7</span><span class="p">);</span> </span><span id="L-4"><a name="L-4"></a> <span class="kd">var</span> <span class="nx">today</span> <span class="o">=</span> <span class="k">new</span> <span class="nb">Date</span><span class="p">();</span> </span><span id="L-5"><a name="L-5"></a> <span class="k">if</span> <span class="p">(</span><span class="nx">today</span><span class="o">&gt;</span><span class="nx">myDate</span><span class="p">){</span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">&#39;hidden&#39;</span><span class="p">).</span><span class="nx">style</span><span class="p">.</span><span class="nx">display</span> <span class="o">=</span> <span class="s1">&#39;none&#39;</span><span class="p">;}</span> </span><span id="L-6"><a name="L-6"></a><span class="o">&lt;</span><span class="err">/script&gt;</span> </span></pre></div> </td></tr></table>
date, display, javascript

JavaScript

Javascript to set CSS selector for browser

1
2
3
4
5
6
7
8
/*
CSS Browser Selector v0.3.1
Rafael Lima (http://rafael.adm.br)
http://rafael.adm.br/css_browser_selector
License: http://creativecommons.org/licenses/by/2.5/
Contributors: http://rafael.adm.br/css_browser_selector#contributors
*/
function css_browser_selector(u){var ua = u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1;},g='gecko',w='webkit',s='safari',h=document.getElementsByTagName('html')[0],b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3')?g+' ff3':is('gecko/')?g:/opera(\s|\/)(\d+)/.test(ua)?'opera opera'+RegExp.$2:is('konqueror')?'konqueror':is('chrome')?w+' '+s+' chrome':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?'mobile':is('iphone')?'iphone':is('ipod')?'ipod':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win':is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent);
https://snipt.net/embed/faff121815802a2af83041183587d58f/
/raw/faff121815802a2af83041183587d58f/
faff121815802a2af83041183587d58f
js
JavaScript
8
2019-07-08T01:57:35
True
False
False
/api/public/snipt/2653/
javascript-to-set-css-selector-for-browser
<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> <a href="#L-8">8</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="cm">/*</span> </span><span id="L-2"><a name="L-2"></a><span class="cm">CSS Browser Selector v0.3.1</span> </span><span id="L-3"><a name="L-3"></a><span class="cm">Rafael Lima (http://rafael.adm.br)</span> </span><span id="L-4"><a name="L-4"></a><span class="cm">http://rafael.adm.br/css_browser_selector</span> </span><span id="L-5"><a name="L-5"></a><span class="cm">License: http://creativecommons.org/licenses/by/2.5/</span> </span><span id="L-6"><a name="L-6"></a><span class="cm">Contributors: http://rafael.adm.br/css_browser_selector#contributors</span> </span><span id="L-7"><a name="L-7"></a><span class="cm">*/</span> </span><span id="L-8"><a name="L-8"></a><span class="kd">function</span> <span class="nx">css_browser_selector</span><span class="p">(</span><span class="nx">u</span><span class="p">){</span><span class="kd">var</span> <span class="nx">ua</span> <span class="o">=</span> <span class="nx">u</span><span class="p">.</span><span class="nx">toLowerCase</span><span class="p">(),</span><span class="nx">is</span><span class="o">=</span><span class="kd">function</span><span class="p">(</span><span class="nx">t</span><span class="p">){</span><span class="k">return</span> <span class="nx">ua</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">t</span><span class="p">)</span><span class="o">&gt;-</span><span class="mi">1</span><span class="p">;},</span><span class="nx">g</span><span class="o">=</span><span class="s1">&#39;gecko&#39;</span><span class="p">,</span><span class="nx">w</span><span class="o">=</span><span class="s1">&#39;webkit&#39;</span><span class="p">,</span><span class="nx">s</span><span class="o">=</span><span class="s1">&#39;safari&#39;</span><span class="p">,</span><span class="nx">h</span><span class="o">=</span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementsByTagName</span><span class="p">(</span><span class="s1">&#39;html&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">],</span><span class="nx">b</span><span class="o">=</span><span class="p">[(</span><span class="o">!</span><span class="p">(</span><span class="sr">/opera|webtv/i</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nx">ua</span><span class="p">))</span><span class="o">&amp;&amp;</span><span class="sr">/msie\s(\d)/</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nx">ua</span><span class="p">))</span><span class="o">?</span><span class="p">(</span><span class="s1">&#39;ie ie&#39;</span><span class="o">+</span><span class="nb">RegExp</span><span class="p">.</span><span class="nx">$1</span><span class="p">)</span><span class="o">:</span><span class="nx">is</span><span class="p">(</span><span class="s1">&#39;firefox/2&#39;</span><span class="p">)</span><span class="o">?</span><span class="nx">g</span><span class="o">+</span><span class="s1">&#39; ff2&#39;</span><span class="o">:</span><span class="nx">is</span><span class="p">(</span><span class="s1">&#39;firefox/3&#39;</span><span class="p">)</span><span class="o">?</span><span class="nx">g</span><span class="o">+</span><span class="s1">&#39; ff3&#39;</span><span class="o">:</span><span class="nx">is</span><span class="p">(</span><span class="s1">&#39;gecko/&#39;</span><span class="p">)</span><span class="o">?</span><span class="nx">g</span><span class="o">:</span><span class="sr">/opera(\s|\/)(\d+)/</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nx">ua</span><span class="p">)</span><span class="o">?</span><span class="s1">&#39;opera opera&#39;</span><span class="o">+</span><span class="nb">RegExp</span><span class="p">.</span><span class="nx">$2</span><span class="o">:</span><span class="nx">is</span><span class="p">(</span><span class="s1">&#39;konqueror&#39;</span><span class="p">)</span><span class="o">?</span><span class="s1">&#39;konqueror&#39;</span><span class="o">:</span><span class="nx">is</span><span class="p">(</span><span class="s1">&#39;chrome&#39;</span><span class="p">)</span><span class="o">?</span><span class="nx">w</span><span class="o">+</span><span class="s1">&#39; &#39;</span><span class="o">+</span><span class="nx">s</span><span class="o">+</span><span class="s1">&#39; chrome&#39;</span><span class="o">:</span><span class="nx">is</span><span class="p">(</span><span class="s1">&#39;applewebkit/&#39;</span><span class="p">)</span><span class="o">?</span><span class="nx">w</span><span class="o">+</span><span class="s1">&#39; &#39;</span><span class="o">+</span><span class="nx">s</span><span class="o">+</span><span class="p">(</span><span class="sr">/version\/(\d+)/</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nx">ua</span><span class="p">)</span><span class="o">?</span><span class="s1">&#39; &#39;</span><span class="o">+</span><span class="nx">s</span><span class="o">+</span><span class="nb">RegExp</span><span class="p">.</span><span class="nx">$1</span><span class="o">:</span><span class="s1">&#39;&#39;</span><span class="p">)</span><span class="o">:</span><span class="nx">is</span><span class="p">(</span><span class="s1">&#39;mozilla/&#39;</span><span class="p">)</span><span class="o">?</span><span class="nx">g</span><span class="o">:</span><span class="s1">&#39;&#39;</span><span class="p">,</span><span class="nx">is</span><span class="p">(</span><span class="s1">&#39;j2me&#39;</span><span class="p">)</span><span class="o">?</span><span class="s1">&#39;mobile&#39;</span><span class="o">:</span><span class="nx">is</span><span class="p">(</span><span class="s1">&#39;iphone&#39;</span><span class="p">)</span><span class="o">?</span><span class="s1">&#39;iphone&#39;</span><span class="o">:</span><span class="nx">is</span><span class="p">(</span><span class="s1">&#39;ipod&#39;</span><span class="p">)</span><span class="o">?</span><span class="s1">&#39;ipod&#39;</span><span class="o">:</span><span class="nx">is</span><span class="p">(</span><span class="s1">&#39;mac&#39;</span><span class="p">)</span><span class="o">?</span><span class="s1">&#39;mac&#39;</span><span class="o">:</span><span class="nx">is</span><span class="p">(</span><span class="s1">&#39;darwin&#39;</span><span class="p">)</span><span class="o">?</span><span class="s1">&#39;mac&#39;</span><span class="o">:</span><span class="nx">is</span><span class="p">(</span><span class="s1">&#39;webtv&#39;</span><span class="p">)</span><span class="o">?</span><span class="s1">&#39;webtv&#39;</span><span class="o">:</span><span class="nx">is</span><span class="p">(</span><span class="s1">&#39;win&#39;</span><span class="p">)</span><span class="o">?</span><span class="s1">&#39;win&#39;</span><span class="o">:</span><span class="nx">is</span><span class="p">(</span><span class="s1">&#39;freebsd&#39;</span><span class="p">)</span><span class="o">?</span><span class="s1">&#39;freebsd&#39;</span><span class="o">:</span><span class="p">(</span><span class="nx">is</span><span class="p">(</span><span class="s1">&#39;x11&#39;</span><span class="p">)</span><span class="o">||</span><span class="nx">is</span><span class="p">(</span><span class="s1">&#39;linux&#39;</span><span class="p">))</span><span class="o">?</span><span class="s1">&#39;linux&#39;</span><span class="o">:</span><span class="s1">&#39;&#39;</span><span class="p">,</span><span class="s1">&#39;js&#39;</span><span class="p">];</span> <span class="nx">c</span> <span class="o">=</span> <span class="nx">b</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="s1">&#39; &#39;</span><span class="p">);</span> <span class="nx">h</span><span class="p">.</span><span class="nx">className</span> <span class="o">+=</span> <span class="s1">&#39; &#39;</span><span class="o">+</span><span class="nx">c</span><span class="p">;</span> <span class="k">return</span> <span class="nx">c</span><span class="p">;};</span> <span class="nx">css_browser_selector</span><span class="p">(</span><span class="nx">navigator</span><span class="p">.</span><span class="nx">userAgent</span><span class="p">);</span> </span></pre></div> </td></tr></table>
browser, css, javascript, selector