2013-09-23 82 views
0

處理動作類後,我有動態屬性,需要作爲查詢字符串追加在靜態URL像"https://www.google.co.in/?zipcode="+zipcode" 我做到這一點。然後我通過請求中的URL將控制權傳遞給JSP。現在從JSP我想在新窗口中打開這個URL,並具有特定的新窗口屬性。使用新窗口屬性在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

爲什麼從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()