Created
July 26, 2015 03:19
-
-
Save sheutettz/66a8c0d8a304c07adad8 to your computer and use it in GitHub Desktop.
some trivial javascript code snippets.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function inherit(ThisClass, SuperClass) { | |
var Anon = function () { | |
}; | |
Anon.prototype = SuperClass.prototype; | |
ThisClass.prototype = new Anon(); | |
ThisClass.prototype.constructor = ThisClass; | |
}; | |
function realize(htmlText) { | |
var div = document.createElement('div'); | |
div.innerHTML = htmlText; | |
if (div.childNodes.length === 1) { | |
return div.childNodes[0]; | |
} | |
else { | |
return Array.prototype.slice.call(div.childNodes); | |
} | |
}; | |
function detectMSDIE() { | |
var ua = window.navigator.userAgent, | |
msie = ua.indexOf('MSIE '), | |
trident = ua.indexOf('Trident/'); | |
return (msie >= 0 || trident >= 0 ); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment