如何关闭FireFox中的showModalDialog,javascript中的Chrome

时间:2012-12-06 07:38:31

标签: javascript alert showmodaldialog

var userChoice = showModalDialog("../Iframe.aspx?FormName=sample.aspx", window,     "dialogTop:300px;dialogLeft:350px;dialogHeight:182px;dialogWidth:370px;help:no;scroll:no;status:no;");        
alert(userChoice); /* here iam not able to get 'Y' */      
if (userChoice == 'Y')       
  return true; else return false;     

 Below is the Sample aspx page:  

  input type="button" value="Yes" onclick="choice('Y')"    

function userChoice(option)     
{       
 window.returnValue = option;    
 alert(window.returnValue);  /* here iam getting 'Y' */
 parent.close(); // I have tried with self.close() also  
}     

1 个答案:

答案 0 :(得分:1)

您无法从模态对话框中关闭parent.window。使用window.close()top.close()关闭模式。

Chrome中存在returnValue的错误,似乎还没有修复,请尝试这些:

showModalDialaog not returning value in Chrome

chromium/issues/detail?id=42939