Skip to content

Instantly share code, notes, and snippets.

View marcelkorpel's full-sized avatar

Marcel Korpel marcelkorpel

View GitHub Profile
@nzakas
nzakas / gist:1119343
Created August 2, 2011 00:38
Autofocus shim
<!-- autofocus shim for older browsers that doesn't impact newer ones -->
<input type="text" name="q" id="q" autofocus>
<script>
(function(textbox){
if (textbox.autofocus !== true){
textbox.focus();
}
})(document.getElementById("q"));
</script>
<div id="lga">
<style>
body{overflow:hidden}#hplogo{position:relative;width:0;margin:0 auto;right:190px;height:160px}.particle{position:absolute;z-index:-1}.circle{-moz-border-radius:160px;-webkit-border-radius:160px;-khtml-border-radius:160px;border-radius:160px}#cpf,#sbl,#fctr{background:transparent}
</style>
<noscript>
&lt;style&gt;#hplogo{right:0;width:auto;background:url(/intl/en_ALL/images/srpr/logo1w.png) no-repeat center}&lt;/style&gt;
</noscript>
<div id="hplogo">
<div class="particle circle" style="background-color: rgb(237, 157, 51); height: 18.337px; width: 18.337px; left: 200.733px; top: 77.5385px;">
</div>
/**
* modified from http://gist.github.com/527683
* only improve slightly to get small
*/
var ie = function(v, p, needle, undef) {
needle = p.getElementsByTagName('br');
while(
p.innerHTML = '<!--[if gt IE ' + (++v) + ']><br><![endif]-->',
@cowboy
cowboy / very-small-ie-detect.js
Created August 21, 2010 13:26 — forked from padolsey/gist:527683
Very small IE detect (aka type coersion ftw)
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 6) then:
// ie === 0
// If you're in IE (>=6) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@TooTallNate
TooTallNate / anotherScript.js
Created June 10, 2010 19:15
"getScriptName" is a cross-browser function to retrieve the absolute URL of the currently executing JavaScript file.
// If no exception is passed into 'getScriptName', it will only
// retrieve the URL of the script where 'getScriptName' is defined.
// In order to get the URL of a different script file, you must
// pass an exception generated in this script file to 'getScriptName'.
try {
(0)();
} catch(ex) {
getScriptName(ex, onScriptNameKnown);
}