Skip to content

Instantly share code, notes, and snippets.

@cgriego
Created December 26, 2008 22:30
Show Gist options
  • Save cgriego/40149 to your computer and use it in GitHub Desktop.
Save cgriego/40149 to your computer and use it in GitHub Desktop.
Testing to see if different script[type] values result in executed JavaScript.
<script type="text/javascript">/* <![CDATA[ */
var types = [
'text',
'application'//,
];
var subtypes = [
'javascript',
'jscript',
'ecmascript',
'livescript',
'javascript1.0',
'javascript1.1',
'javascript1.2',
'javascript1.3',
'javascript1.4',
'javascript1.5'//,
];
var subtypePrefixes = [
'',
'x-'//,
];
var mimeType;
for (var i=0; i < subtypes.length; i++) {
for (var j=0; j < types.length; j++) {
for (var k=0; k < subtypePrefixes.length; k++) {
mimeType = types[j] + '/' + subtypePrefixes[k] + subtypes[i];
document.write(
'<div>' +
'<script type="' + mimeType + '">document.write("<em>PASS</em>");</' + 'script>' +
mimeType +
'</div>'// +
);
};
};
};
/* ]]> */</script>
<script type="text/javascript">/* <![CDATA[ */
divs = document.getElementsByTagName("div");
var fail = document.createElement("strong");
fail.innerHTML = "FAIL";
for (var i = divs.length - 1; i >= 0; i--) {
if (!divs[i].getElementsByTagName("em").length) {
divs[i].insertBefore(fail.cloneNode(true), divs[i].firstChild);
}
}
/* ]]> */</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment