我有一个当前正在使用 showModalDialog 的开启窗口。需要替换它,因为它已被弃用。模式对话框窗口有一个window.returnvalue。因此,我无法简单地使用 Window.Open 来替换 showModalDialog。
有什么办法可以解决这个问题吗?下面是示例代码 来电者:
retval = window.showModalDialog('abc.asp?user=' SomeUser + "center=no;dialogwidth:600px;dialogheight:400px;dialogwidth:600px;dialogheight:400px;help=No;status=yes")
//DO SOMETHING WITH retval
模态对话框窗口:
<script>
function SaveMe()
{
window.returnValue = 'Some value that is needed in caller';
window.close();
}
最佳答案
您可以尝试windows.open() .
调用弹出窗口:
retval = window.open(......);
//bind close event to retval
retval.onunload = getReturnValue;
和函数getReturnValue
function getReturnValue(){
//now value is retval.returnValue or something you bind
console.log(retval.returnValue);
}
我昨天刚刚修复了我的网站。
关于javascript - 返回值时如何替换showModalDialog,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39256281/