Skip to content

Instantly share code, notes, and snippets.

@sheutettz
Created July 26, 2015 03:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sheutettz/66a8c0d8a304c07adad8 to your computer and use it in GitHub Desktop.
Save sheutettz/66a8c0d8a304c07adad8 to your computer and use it in GitHub Desktop.
some trivial javascript code snippets.
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