win = window.open('a.htm','','');
win.onload = function(){
}

解决方案 »

  1.   

    win = window.open('a.htm','','');
    win.document.body.onload = function(){
    }
      

  2.   

    win = window.open("","");
    win.onload=function(){alert()}
    我之前就这样写过,但不好用
      

  3.   

    <SCRIPT>
    onload=function()
    {
    for(var i=0;i<myTab.rows.length;i++)
    {
    for(var j=0;j<myTab.rows[i].cells.length;j++)
    {
    if(i!=0)
    {
    eval("myTab.rows["+i+"].cells["+j+"].onclick=function(){window.opener.form1.project.value = myTab.rows["+i+"].cells[1].innerText}");

    eval("myTab.rows["+i+"].cells["+j+"].onmouseup=function(){opener.focus()}");
    eval("myTab.rows["+i+"].cells["+j+"].onmouseup=function(){self.close()}");
    }
    }
    }
    }
    </SCRIPT>
    这是我一个程序里的代码,是单击选种表格中一行返回第2格内容并关闭自己,你看看有没有用
      

  4.   

    <html>
    <head>
    <title>ParentWin</title>
    <script language=javascript>
    <!--function doSubWinLoad(subWin){
    window.alert("这是父窗口的对话框");
    subWin.alert("这是子窗口的对话框");
    }
    function openSubWin(){
    open('subWin.htm','sub');
    }
    </script></head>
    <body>
        <a href="javascript:openSubWin();">打开</a>
    </body>
    </html>---------------------------------------
    subWin.htm:
    <html>
        <head><title>subWin</title></head>
        <body onload="window.opener.doSubWinLoad(window);">
            这是子窗口
        </body>
    </html>
      

  5.   

    就是子窗口不写代码,让父窗口判断子窗口的onload
      

  6.   

    这样应该是不行的,因为子窗口里的代码全部是写进去的,所以第一次载入是没有事件发生的,你可以看看:
    当打开子窗口后,没有alert,但刷新之后会有
    <script language="javascript">
    <!--
    var w=window.open("","","")
    w.document.write("<script>onload=function(){alert('blueDestiny')}</scr"+"ipt>");
    //-->
    </script>
      

  7.   

    当然有变通的办法。在子窗口内加入hidden,初始为0,当为0时,hidden为1,刷新页面。也可以出现alert但更好的办法,我觉得还不如直接把事件加入body末端,这样把一个true值告诉给opener,也可以达到你的目的。
      

  8.   

    <script language=javascript>
    function outPut()
    {
    var text = "admin";
    var win = window.open("Untitled2.html","mywin", "menubar=yes,width=400,height=100,resizeable=yes");win.document.onreadystatechange=function(){  
               if(document.readyState=="complete"){  
                         win.document.form1.username.value=text;
               }  
    }  }</script><!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" />
    <title>无标题文档</title>
    </head><body>
    <a href="#" onClick="outPut()">ssss</a>
    <form id="form1" name="form1" method="post" action="">
      <label>
      <input name="username" type="text" id="username" />
      </label>
    </form>
    </body>
    </html>