我有一个js文件和一个html文件野兔是代码
testjs.js
function DynamicDiv() {
alert('enter');
var dynDiv = document.createElement("div");
dynDiv.id = "divDyna";
dynDiv.innerHTML = "Created using JavaScript";
dynDiv.style.height = "20px";
dynDiv.style.width = "300px";
dynDiv.style.backgroundColor = 'gray';
document.body.appendChild(dynDiv);
}
我的html代码如下
<html>
<head>
<TITLE>Test Page</TITLE>
<script type="text/javascript" src="testjs.js" language="javascript"></script>
<script type="text/javascript" src="jquery-1.4.2.js" language="javascript"></script>
<script type="text/javascript" language="javascript">
//"Global" variable accessible to all
//$(document).ready(DynamicDiv());
</script>
</head>
<body onLoad="DynamicDiv()">
<input id="Button1" type="button" value="Using JS" onclick="" />
<div id="Layer1" style="position: absolute; width: 100%; height: 17px; z-index: 1; left: 0px; top: 3px;">
<div align="right"><a href="http://www.uspto.gov/main/patents.htm">PATENTS</a> </div>
</div>
</body>
</html>
但我无法调用该函数