document.myIframe.document.onclick
这样看看

解决方案 »

  1.   

    <html>
    <script lanuage="javascript">
    window.onload=function(){
    iframe1.document.onclick=test1;
    };

    function test1(){
    alert( 1 );
    }
    </script>
    <body>
    <iframe id="iframe1" src="2.html"></iframe>
    </body>
    </html>
      

  2.   


    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
        <title>无标题页</title>
        <script language="javascript" type="text/jscript" src="Js/JScript.js"></script>
        <script language="javascript">
            </script>
        
    </head>
    <body>
    <iframe id="frame1"  ></iframe>
    </body><script language="jscript">
    function init()
    {
       frame1.document.onclick =aaa
    }function aaa()
    {alert("sub");}    function loadfunc()
    {
       document.getElementById("frame1").src="B.html";
      //  writeCookie("xxmainworld","")
    }
    loadfunc();init();
    </script></html>
    这样就不行了,如果把loadfunc注释掉可以,但是我要用js动态给src赋值,然后再定义iframe里的onclick事件,怎么做啊??
      

  3.   

    function init()
    {
    if( frame1.document.readyState == "complete" ){
    frame1.document.onclick =aaa;
    return;
    }
    window.setTimeout("init();",100);
    }
      

  4.   

    画面加载需要时间,
    你要等页面加载完成后再设定onclick的处理事件.