javascript - 返回值时如何替换showModalDialog

标签 javascript google-chrome asp-classic showmodaldialog

我有一个当前正在使用 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/

相关文章:

javascript - JavaScript 中的搜索栏样式属性问题

javascript - 为什么我在 node.js 中使用 parseInt 会得到奇怪的结果? (与 chrome js 控制台的结果不同)

html - 自最近更新以来,从检查元素样式复制会换行

javascript - 从ROOT加载文件

javascript - 如何使用 Jasmine 对 $scope.broadcast、$scope.$on 进行单元测试

javascript - TinyMCE 弹出窗口在 Chrome 中太小

javascript - Webusb API navigator.usb.requestDevice

asp.net - 获取 "This type of page is not served",如何在本地机器上的 Visual Studio 中运行经典 asp?

javascript - 显示在网站上的倒计时器

.net - 向 .NET 程序集中的 ADODB 命令添加参数时出错