<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>

解决方案 »

  1.   

    还可以连接事件:
    <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>
      

  2.   

    to emu(ston)请问你那个document.body.text这个test是什么啊?为何我用时提示document.body为空或不是对象。
      

  3.   

    我的意思是<body bgcolor=#000000 link=#000000>就像那些bgcolor的属性是属于BODY的属性,
    通过字符串的形式加到<body .... >后面(就是...这上面)
      

  4.   

    document.body.test="test"的意思是给body一个属性叫做test,并给这个属性赋值为“test”
    document.body.onclick=alert 的意思是把body的onclick事件绑定到alert函数上。
      

  5.   

    <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.bgColor = "red"
    }
    //-->
    </SCRIPT></body>
    </html>