Skip to content

Instantly share code, notes, and snippets.

@natecavanaugh
Created September 28, 2012 00:53
Show Gist options
  • Save natecavanaugh/3797359 to your computer and use it in GitHub Desktop.
Save natecavanaugh/3797359 to your computer and use it in GitHub Desktop.
detect_js_version
var ifr = document.createElement('iframe');
ifr.src = 'javascript:;';
ifr.style.display = 'none';
document.body.appendChild(ifr);
var js = [];
for (var i = 0; i < 11; i++) {
js.push('<script ' + (i !== 0 ? 'language="Javascript1.' + i + '"' : 'type="text/language"') + '">window.jsversion = 1.'+ i +';</script>');
}
ifr.contentWindow.document.write(js.join(''));
console.log(ifr.contentWindow.jsversion);
ifr.parentNode.removeChild(ifr);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment