<%@ page
language="java"
import="java.util.*,java.net.*"
pageEncoding="UTF-8"
%>
<a
name="A0"
id="A0"
></a>
<form action="#">
<input id="content" />
<input
id="subForm"
type="submit"
οnclick="return testClike();"
/>
<input
id="test"
type="button"
value="test"
/>
</form>
<%
for (int i = 0; i <= 10; i++) {
out.println("<p>" + i + "</p>");
}
%>
<a href="#A0">返回顶部</a>
<script type="text/javascript">
function $(id) {
return document.getElementById(id);
}
window.onload = function() {
alert("刷新页面啦.");
}
var testClike = function() {
if (!$("content").value) {
alert("空值了。");
} else {
alert($("content").value);
return true;
}
return false;
}
$("test").onclick = testClike;
//$("subForm").onclick = testClike;
var onClick = function(obj) {
obj.onclick = function() {
alert($("content").value);
}
}
</script>
<body>
<input
name="btnClick"
type="button"
id="btnClick"
value="点我"
/>
<script
type="text/javascript"
language="javascript"
>
//此JS代码必须放到body结束之前才有效
function $(id) {
return document.getElementById(id);
}
$("btnClick").onclick = function() {
alert("我被激活啦!");
}
</script>
</body>