<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
</head>
<body>
<button onclick="tesFunc()">test</button>
<SCRIPT LANGUAGE="JavaScript">
<!--
function tesFunc()
{
document.body.test="test"
alert(document.body.outerHTML);
alert(document.body.test);}
//-->
</SCRIPT></body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
</head>
<body>
<button onclick="tesFunc()">test</button>
<SCRIPT LANGUAGE="JavaScript">
<!--
function tesFunc()
{
document.body.test="test"
alert(document.body.outerHTML);
alert(document.body.test);}
//-->
</SCRIPT></body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
</head>
<body>
<button onclick="tesFunc()">test</button>
<SCRIPT LANGUAGE="JavaScript">
<!--
function tesFunc()
{
document.body.test="test"
document.body.onclick=alert;
alert(document.body.outerHTML);
}
//-->
</SCRIPT></body>
</html>
通过字符串的形式加到<body .... >后面(就是...这上面)
document.body.onclick=alert 的意思是把body的onclick事件绑定到alert函数上。
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
</head>
<body>
<button onclick="tesFunc()">test</button>
<SCRIPT LANGUAGE="JavaScript">
<!--
function tesFunc()
{
document.body.bgColor = "red"
}
//-->
</SCRIPT></body>
</html>