网站的基本布局,苏州著名网站建设,文化馆的网站怎么建设,网站建设心得.doc个人感觉模态窗口在做网站的时候#xff0c;使用到的比较少#xff0c;前段时间在做项目时要实现以模态窗口传值和接收返回值#xff0c; 模态窗口传值实现比较简单#xff0c;但是做好后发现在Chrome浏览器中接收不到返回值#xff0c;修改好Chrome浏览器的问题后 大概过… 个人感觉模态窗口在做网站的时候使用到的比较少前段时间在做项目时要实现以模态窗口传值和接收返回值 模态窗口传值实现比较简单但是做好后发现在Chrome浏览器中接收不到返回值修改好Chrome浏览器的问题后 大概过了有两个星期又发现在IE6下会报错最终在网上搜索解决办法才修改好 代码 A为父页面B为子页面 A页面代码 //打开选择客户的模态窗口function sc(tag) {var recdata false;var strDialogFeatures statusno;centeryes;helpno;dialogWidth700px;dialogHeight600px;scrollyes;resizeno;recdata showModalDialog(Modal_List_forother.aspx?id tag , newwindow, strDialogFeatures); //此处的if判断语句必须需要如果直接用recdatawindow.returnValue赋值的话在IE6下会无法获取到返回值至于原因我也不清楚IM SORRY o(╯□╰)oif (recdata undefined) {recdata window.returnValue;}if (recdata ! undefined) {//刷新父窗口 此处可以不刷新 因项目功能需要 所以在此处做了刷新操作var url window.location.href.toString(); //此处省略对变量url的部分操作根据需要实现的功能不同代码也会不一样window.location.href url;}} B页面代码 首先在要想在IE6下也能接收模态窗口返回值 先要在B页面的head部分添加代码base target_self / 如下 head runatservertitle子窗口/titlelink hrefStyles/basic.css relstylesheet typetext/css /base target_self /
/head 要想从后台返回值到父页面去我们还需在页面的cs文件中添加如下代码 string strscripts ;strscripts strscripts script type\text/javascript\; //这是原先的返回值代码也是正确的只是嫌太长不想用//strscripts strscripts if(window.opener!undefined){ window.opener.returnValue name ; }else{window.returnValue name// ;} window.close();/script;strscripts strscripts window.returnValue name ;window.close();/script;ClientScript.RegisterStartupScript(ClientScript.GetType(), myscript, script type\text/javascript\ window.returnValue name ;window.close();/script); 转载于:https://www.cnblogs.com/xuxw/p/3416455.html