javaScript:弹出窗口转向操作后不打开新窗口;链接变量嵌套

window.open()或window.showModalDialog开启新窗口后,如果有form submit 或window.loaction动作,系统会打开一个新的页面。如果想操作还在原来打开的窗口则需要加点修改:

添加一个popupWindow.jsp
<%String sSourceURL = (String)request.getParameter("src");%>
<html>
<body>
<iframe name="childFrame" id="childFrame" height="100%" width="100%" src="<%=sSourceURL%>"></iframe>
</body>
</html> 

系统不直接打开url,而是先转给popupWindow.把src放入一个iframe中,来保证后面的操作不会新开一个窗口。
如:
function openPhotoWin(staffCode)
{
  src = 'popupWindow.jsp?src='+escape("maintEmployeePhoto.do?method=init&staffCode="+staffCode);
 openChildWindow(src, '', 'dialogWidth: 778px; dialogHeight:560px; center: Yes; help: no; status:no;', 'Y');
}
//open child window
function openChildWindow(src, inputObj, windowStyle) {
 var pageStatus=true; 
 aReturn = window.showModalDialog(src, inputObj, windowStyle );
 return aReturn; 
}

上面例子中src为链接,其中还带两个参数method,staffCode
maintEmployeePhoto.do?method=init&staffCode="+staffCode

如果src = 'popupWindow.jsp?src='+escape("maintEmployeePhoto.do?method=init&staffCode="+staffCode);
改为src = 'popupWindow.jsp?src='+"maintEmployeePhoto.do?method=init&staffCode="+staffCode;
在popupWindow.jsp中,系统
String sSourceURL = (String)request.getParameter("src");
sSourceURL =
maintEmployeePhoto.do?method=init;
而我原本想要
sSourceURL =maintEmployeePhoto.do?method=init&staffCode=staffCode;
可以比较出来前一中方法把staffCode变量已经丢掉,而这不是我想要的。为什么这样呢?因为前中方法,系统默认&staffCode为 popupWindow.jsp所有,而src拿不到。
通过
escape("maintEmployeePhoto.do?method=init&staffCode="+staffCode)就可以把整个值传给src 了。



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值