如何在用showModalDialog打開頁面后,點擊頁面上的按鈕,關閉頁面,並執行父頁面的事件?請幫忙,留下JS代碼,謝謝

解决方案 »

  1.   

    var itemNumber = window.showModalDialog('ItemListPopWindow.aspx',window,'dialogWidth:920px;dialogHeight:600px;help:0;resizable:0;status:0;scroll:0;');
            var undefined;
            if (itemNumber != undefined && itemNumber != "0") 
            {   
                document.getElementById("<%=btnOK.ClientID %>").click(); 
            }
      

  2.   

    1.
    showModal 的时候将父窗体的window对象作为参数传给子窗体:// parent.html
    var args = {"parentWin" : window }; // 这里我作为子属性包装传递,
    // 还可以指定其他参数
    // args.firstName = "Jack";
    var retVal = window.showModalDialog('child.aspx', args);// child.html
    // 得到父窗体的 window 对象
    var parentWin = window.dialogArguments.parentWin;
    window.location.href = "newpage.html";
      

  3.   

    window.location.href = "newpage.html";
    >>>
    parentWin.location.href = "newpage.html";
    2.
    能不能在子頁面中添加刷新的JS,如果在父頁面當中刷新,無倫子頁面是點那個關閉的,都會刷新!
    請幫忙解決下!謝謝!
    --------------------------
    那么你可以对返回值做标记,表示执行哪些事件// child.html
    // ...
    window.returnValue = {"ShouldRefresh": true};
    // more values;
    window.returnValue.result = 911;
    // ...
    window.close();// parent.html
    var retVal = window.showModalDialog('child.html', args);
    if(retVal) { // 如果用户直接关闭,返回值为空
       if(retVal.ShouldRefresh) window.location.href = "newpage.html";
       // else if
       alert(retVal.result);
    }