如何在弹出窗口中调用操作

How to call an action in pop up window

本文关键字:调用 操作 窗口      更新时间:2023-09-26

我有一个JSP,其中有一个打开弹出窗口的链接(假设在struts xml中进行一些操作)。在该窗口中,我有 4 个下拉列表。一旦用户选择这 4 个下拉列表并单击提交按钮,就会调用一个操作,如 struts xml 中所述。,相应的映射页面必须显示为主页面,并且必须关闭弹出窗口。任何帮助/想法如何做到这一点?我是编程新手。

提前感谢,阿伦

在主.jsp,

<a href="http://localhost:8080/hello.action" onclick="javascript:void window.open('http://localhost:8080/Strutslearning/hello.action','1379313271736','width=700,height=500,toolbar=0,menubar=1,location=0,status=1,scrollbars=1,resizable=1,left=0,top=0');return false;">Pop-up Window</a>

在弹出的 jsp 中

 <script type="text/javascript">
 function checkForm(){
     window.close();
     target="main"
     return true;
 }
 </script>

<body>
<form action="selectAction.action" onsubmit="return checkForm(this)">
<s:select name="mylist" list="%{mylist}"></s:select>
<s:submit ></s:submit>
</form>

target="_parent"添加到表单中:

<form action="selectAction.action" 
      onsubmit="javascript:window.close();" 
      target="_parent">

请注意,在 <a> 元素中,您不需要两次引用 Action:使用 href + target="_blank"href="#" + onclick="window.open(...)" ,而不是两者兼而有之。