在使用 window.showModalDialog 方法弹出模态对话框时,可以通过以下步骤处理返回值:
window.showModalDialog 方法时,可以传入一个参数用于指定返回值的键名,例如:var returnValue = window.showModalDialog("dialog.html", {}, "dialogWidth:500px; dialogHeight:300px");在弹出的模态对话框中,可以通过以下代码将需要返回的值赋给 window.returnValue:window.returnValue = "value";在父窗口中可以通过以下方式获取返回值:if (returnValue) { console.log(returnValue);}需要注意的是,window.showModalDialog 方法已经被废弃,推荐使用 window.open 方法来替代。


