showModalDialog改进版,包括Chrome下的特殊处理

来源:互联网 发布:java生成jsp页面 编辑:程序博客网 时间:2024/06/03 19:55

继了解了上篇文章(http://blog.csdn.net/tegwy/article/details/7735814)后对以前showModalDialog脚本做相关改进。


父页面

if(window.ActiveXObject){ //IE$("#choose_entp").click(function(){var returnValue = window.showModalDialog("SelectEntpInfo.do?mod_code=${af.map.mod_code}&xxx=" + Math.random(), window, "dialogWidth:630px;status:no;dialogHeight:440px");if(returnValue != null ){setValue(returnValue.id,returnValue.name);}});}else{  //非IE$("#choose_entp").click(function(){window.open("SelectEntpInfo.do?mod_code=${af.map.mod_code}&xxx=" + Math.random(), 'newwindow','height=440,width=630,top=150,left=300,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no');});}function setValue(id,name){$("#entp_id").val(id);$("#entp_name").val(name);}


子页面处理:

function getReturnValue(select_id,select_name){if(window.ActiveXObject){ //IEwindow.returnValue = {id : select_id,name : select_name} ;window.close();}else{ //非IEif(window.opener) {window.opener.setValue(select_id,select_name) ;}window.close();}}

试了下,貌似以前翻页父窗口引用的问题也解决了。比之前(http://blog.csdn.net/tegwy/article/details/4139785)用的方法要方便些。