本文介绍在Chrome浏览器中使用showModalDialog时返回值可能为undefined的问题及解决方法。通过判断返回值是否为undefined,若为undefined则使用window.returnValue获取返回值,从而确保在不同浏览器中都能正确获取对话框返回值。
Chrome浏览器showModalDialog返回值问题
本文详细介绍在Chrome浏览器中使用showModalDialog函数时,返回值可能为undefined的问题及其解决方法。
主页面代码示例如下:
主页面代码示例
<script type="text/javascript">
function SelectGroupCust() {
var temp = window.showModalDialog("Default2.aspx?xx=" + Date(), "", "dialogWidth=800px;dialogHeight=600px;help=no;center=yes;");
//for chrome
if (temp == undefined) {
temp = window.returnValue;
}
alert(temp);
return true;
}
</script>
详细页面代码示例如下:
详细页面代码示例
<script language="javascript" type="text/javascript">
function ReturnAddressee() {
if (window.opener != undefined) {
window.opener.returnValue = "1";
}
else {
window.returnValue = "2";
}
window.close();
}
</script>
更多关于JavaScript相关内容感兴趣的读者可查看本站专题:《JavaScript错误与调试技巧总结》、《JavaScript数学运算用法总结》、《JavaScript中json操作技巧总结》、《JavaScript切换特效与技巧总结》、《JavaScript查找算法技巧总结》、《JavaScript动画特效与技巧汇总》、《JavaScript数据结构与算法技巧总结》及《JavaScript遍历算法与技巧总结》
希望本文所述对大家JavaScript程序设计有所帮助。