The problem I'm having is the code I wrote works perfectly fine in the editor (Komodo), it works in Firefox and it works in Safari. However, I get an error every time I try to run it in IE8. I tried looking at the "Developer Tools", and it says the "onclick" function in the <button> is an invalid argument.
Anyway, here's the code...any ideas? Thanks!
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Chapter 12 Homework - Troy Christensen</title>
<style type= "text/css">
h1 {
font-size: 50pt;
padding: 0px;
margin: 0px;}
</style>
<script type= "text/javascript">
<!--
var count = 0;
function replaceNode()
{
var currentNode = document.getElementById("counter");
var newNode = createNewNode(count);
document.getElementById("division").replaceChild(newNode, currentNode);
}
function createNewNode(text)
{
var newNode = document.createElement("h1");
newNode.id = "counter";
newNode.appendChild(document.createTextNode(text));
count++;
return newNode;
}
//-->
</script>
</head>
<body onload= "replaceNode();">
<div id= "division">
<h1 id= "counter"></h1>
<button type= "button" id= "button" value= "Click to Count" onclick= "replaceNode();" >Click to Count</button>
</div>
</body>
</html>

New Topic/Question
Reply



MultiQuote



|