2012-07-09 139 views
0

我必须在ext js中的一个按钮的点击事件中加载一个新的jsp页面。我把这样的代码Window.open()in ext Js

listeners: { 
     'click': function(){ 
      alert("hai"); 
      window.open('<%=request.getContextPath()%>/jsp/dashboard/helpwindow.jsp','_blank','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=700,height=600'); 
     } 
    } 

但它不给我结果。 '<%= request.getContextPath()%>'会造成问题。

现在TH新窗口的URL

http://localhost:8080/hiring/%3C%=request.getContextPath%28%29%%3E/jsp/dashboard/helpwindow.jsp 

开放,但我需要的URL

http://localhost:8080/hiring/jsp/dashboard/helpwindow.jsp 

请帮我解决这个问题。

+1

看来您的代码在<% and %>标记之间没有执行。尝试使用空格,也许使用out.print:<%out.print(request.getContextPath()); %> – 2012-07-09 11:51:40

+0

我试过了。但没有工作。 '<%out.print(request.getContextPath()); %>/jsp/dashboard/helpwindow.jsp' – 1355 2012-07-09 12:06:48

+0

它与Ext无关。 js文件永远不会被服务器解释,因此标签没有意​​义。 – 2012-07-09 13:27:32

回答

0
listeners: { 

    'click': function() {     
     var serverPath = window.location.href; 
     var serverPathIndex = serverPath.lastIndexOf("/"); 
     window.open(serverPath.substring(0, serverPathIndex) + '/jsp/dashboard/helpwindow.jsp','_blank','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=700,height=600'); 
    } 
}