当前位置: 代码迷 >> JavaScript >> js弹窗(showModalDialog)封闭返回传递参数及激活事件
  详细解决方案

js弹窗(showModalDialog)封闭返回传递参数及激活事件

热度:168   发布时间:2012-07-04 19:33:54.0
js弹窗(showModalDialog)关闭返回传递参数及激活事件
父窗口中的js
function openwin(){ 
    x=window.showModalDialog("win.html",window,"dialogHeight:200px;dialogWidth:400px;center:yes;help:No;resizable:No;status:No;"); 
    if (x=="haha"){//当关闭时,判断返回值
        alert(x);//关闭窗口后激活alert
    }
  } 


子窗口中的js
function closethis(){ 
       Window.returnValue = "haha"; //定义返回值
      close(); 
} 


<input type="button" onclick="closethis()" value="关闭" />


当触发onclick事件时调用closethis()函数 该函数返回"haha"  if (x=="haha")//当关闭时,判断返回值 如果相等则 alert(x).

?

  相关解决方案