Skip to content

Instantly share code, notes, and snippets.

@ifandelse
Created April 28, 2011 03:59
Show Gist options
  • Save ifandelse/945771 to your computer and use it in GitHub Desktop.
Save ifandelse/945771 to your computer and use it in GitHub Desktop.
Testing Script Element Insertion with jQuery and IE
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<script type="text/javascript" src="js/jquery-1.5.2.js"></script>
<script type="text/javascript">
$(function(){
var node = $("<script/>", {
"type": "text/javascript",
"id":"myTemplate"
,"textContent":"alert('Hey it worked!')" // this works in IE
})['appendTo']("body");
var nodeB = $("<div />", {"text": "Did this work??!"}).appendTo("body");
var node = $("<script/>", {
"type": "text/javascript",
"id":"myTemplateB"
,"text":"alert('Hey it worked again!')" // this fails in IE
})['appendTo']("body");
var nodeB = $("<div />", {"text": "Did this work AGAIN??!"}).appendTo("body");
});
</script>
</head>
<body>
<h3>Testing Script Element Insertion w/jQuery and IE.</h3>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment