简体   繁体   中英

How to replace showModalDialog when value is being returned

I have a opener window that is currently using showModalDialog. This needs to be replaced because its deprecated. The modal dialog window has a window.returnvalue. As a result, I am unable to simply use Window.Open to replace showModalDialog.

Is there anyway to work around this problem? Below is a sample code Caller:

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

Modal Dialog Window:

  <script>
  function SaveMe()
  {
      window.returnValue = 'Some value that is needed in caller';
      window.close();
  }

You can try windows.open() .

Call popup:

retval = window.open(......);
//bind close event to retval
retval.onunload = getReturnValue;

And function getReturnValue

function getReturnValue(){
//now value is retval.returnValue or something you bind
console.log(retval.returnValue);
}

I just fixed my website yesterday.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM