<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link rel="stylesheet" href="css/PublicStyle.css" type="text/css" />
<link rel="stylesheet" href="css/WorkAreaStyle.css" type="text/css" />
<title>无标题文档 </title>
</head><body><input id="xxx" type="hidden" value="" />
<input id="btn" type="button" value="test hd" onclick="test(1);" /> <!--主动调用-->
<div id="cccccc">11111111111</div>
</body>
<script language="javascript" type="text/javascript">function changeColor( color ) {
//alert(color)
    this.style.color = color;
}function setBodyColor() {
    //apply方法设置上下文为body元素
    //第一个参数为设置的上下文,
    //第二个参数是一个被作为参数传递给函数的数组
    // of arguments that gets passed to the function
    changeColor.call( document.getElementById("cccccc"), arguments[0][0] );
}
setBodyColor(['red','blue'])
</script>
</html> 

解决方案 »

  1.   

    那他这样写法( changeColor.apply( document.body, arguments );
    )应该不对了,因为arguments是数组,那这里(function changeColor( color ) {
    //alert(color)
        this.style.color = color;
    }
    )color也是数组了!
      

  2.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <link rel="stylesheet" href="css/PublicStyle.css" type="text/css" />
    <link rel="stylesheet" href="css/WorkAreaStyle.css" type="text/css" />
    <title>无标题文档 </title>
    </head><body><input id="xxx" type="hidden" value="" />
    <input id="btn" type="button" value="test hd" onclick="test(1);" /> <!--主动调用-->
    <div id="cccccc">11111111111</div>
    </body>
    <script language="javascript" type="text/javascript">function changeColor( color ) {
    //alert(color)
        this.style.color = color;
    }function setBodyColor() {
        //apply方法设置上下文为body元素
        //第一个参数为设置的上下文,
        //第二个参数是一个被作为参数传递给函数的数组
        // of arguments that gets passed to the function
        changeColor.apply(document.getElementById("cccccc"),arguments);
    }
    setBodyColor('red','blue')
    </script>
    </html>