| 发表于:2007-08-06 08:24:412楼 得分:0 |
<html> <script> function addevent() { } function go2(){ alert( 'hello from inserted script. '); } </script> <body onload= "addevent(); "> <input type= "button " id= "test " onclick= "go2() " value= "test "> </body> </html> body onload的时候test还没有加载完毕,所以并不能直接操作 而且,eval()的确是可以动态执行字符串的最好办法 你的方法有时候由于script加载运行需要的时间问题,会造成错误 | | |
|