<html>
<head>
<title>
Preview ActiveX Controls In Internet Explorer</title></head>
<body>
<INPUT TYPE="button" id="test" value="test"><SCRIPT LANGUAGE="JavaScript">
var o = document.getElementById("test");
o.attachEvent("onclick",function(){txtClick(o)});
function txtClick(obj)
{
obj.value = "fdasfdasf";
}
</SCRIPT>
</body></html>

解决方案 »

  1.   

    少写几句也一样的!<html>
    <head>
    <title>
    Preview ActiveX Controls In Internet Explorer</title></head>
    <body>
    <INPUT TYPE="button" id="test" value="test"><SCRIPT LANGUAGE="JavaScript">
    var o = document.getElementById("test");
    o.onclick = function ()
    {
       this.value = "fdasfdasf";
    }
    </SCRIPT>
    </body></html>
      

  2.   

    yixianggao() ,好像你这样写,代码就马上执行了,我是想让它不要马上执行.只是赋上这个事件的内容而已.
      

  3.   

    document.getElementById("button1").onclick = function()
    {
      alert("click is runing!");
    };
      

  4.   

    不用在BUTTEN上设置属性ONCLICK="",用document.getElementById("button1").onclick,也可以达到ONCLICK=""一样的效果吗?
      

  5.   

    不用在BUTTEN上设置属性ONCLICK="",用document.getElementById("button1").onclick,也可以达到ONCLICK=""一样的效果吗?感觉应该有这个属性ONCLICK吧 不然 怎么触发这个事件呢!