日期:2014-05-16  浏览次数:20395 次

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).

?