处理动作类后,我有动态属性需要作为查询字符串附加到静态URL中,如"https://www.google.co.in/?zipcode="+zipcode"
到目前为止我已经完成了。然后我将控制权传递给带有请求URL的JSP。现在从JSP我想在新窗口中打开这个带有特定新窗口属性的URL。
这是我试试的jsp:
<%
String redirectURL = (String)request.getAttribute("url2redirect");
response.sendRedirect(%><javascript:openNewWindow()><%
%>
<script>
function openNewWindow() {
var screenWidth = screen.width;
var screenHeight = screen.height;
var contactUsWidth = screenWidth*90/100;
var contactUsHeight = screenHeight*90/100;
window.open('<%=redirectURL%>','appointment','scrollbars,menubar=no,width='+contactUsWidth+',height='+contactUsHeight+',resizable=no,toolbar=no,location=no,status=no,copyhistory=yes,left=0,top=0,screenX=0,screenY=0');
}
</script><%);%>
它没有工作给出语法错误....这是正确的方法吗? 我们如何在具有不同窗口属性的新窗口中打开此URL。
答案 0 :(得分:0)
为什么要从response.sendRedirect()
调用此javascript方法?
这不起作用吗?
<%
String redirectURL = (String)request.getAttribute("url2redirect");
%>
<script>
function openNewWindow() {
var screenWidth = screen.width;
var screenHeight = screen.height;
var contactUsWidth = screenWidth*90/100;
var contactUsHeight = screenHeight*90/100;
window.open('<%=redirectURL%>','appointment','scrollbars,menubar=no,width='+contactUsWidth+',height='+contactUsHeight+',resizable=no,toolbar=no,location=no,status=no,copyhistory=yes,left=0,top=0,screenX=0,screenY=0');
}
</script>
如果要在加载页面时加载弹出窗口,请从正文onload调用openNewWindow()