温馨提示×

window.showmodaldialog返回值处理

小樊
81
2024-07-01 18:41:39
栏目: 智能运维

在使用 window.showModalDialog 方法弹出模态对话框时,可以通过以下步骤处理返回值:

  1. 在调用 window.showModalDialog 方法时,可以传入一个参数用于指定返回值的键名,例如:
var returnValue = window.showModalDialog("dialog.html", {}, "dialogWidth:500px; dialogHeight:300px");
  1. 在弹出的模态对话框中,可以通过以下代码将需要返回的值赋给 window.returnValue
window.returnValue = "value";
  1. 在父窗口中可以通过以下方式获取返回值:
if (returnValue) {
  console.log(returnValue);
}

需要注意的是,window.showModalDialog 方法已经被废弃,推荐使用 window.open 方法来替代。

0