<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>attrTest</title>
<script>
function createNewButton(){
var body=document.getElementById("body");
var newBtn=document.createElement("input");
newBtn.setAttribute("type","button");
newBtn.setAttribute("value","show text");
newBtn.setAttribute("onclick","show()");//此句似乎在ie浏览器不起作用,无法调用show()函数
body.appendChild(newBtn);
}
function show(){
document.getElementById("txt").innerHTML="new button content....";
}
</script>
</head>
<body id="body">
<p id="txt">new button text show here</p>
<input type="button" onclick="createNewButton()" value="Create new button"/>
</body>
</html>