页面A的部分代码:
<tr>
<td><b><%= flabel.getProperty("domainadmin_adminid") %></b></td>
<td>
<span id='adminuid' ><%= db.getAdminUID() %></span>
<input type="hidden" name="ADMINUID" id="ADMINUID">
<input type="hidden" name="beforeadminuid" value="<%= db.getAdminUID() %>">
<input type="button" name="chkid" value="<%=flabel.getProperty("domainadmin_checkid") %>" onclick="window.open('useroptlist.jsp?usrtype=allusr&fspan=adminuid&fvalue=ADMINUID','popuppage','width=100,height=300,top=100,left=100, scrollbars=yes, resizable=yes');" >
</td>
<td><%=flabel.getProperty("domainadmin_msgadminid") %></td>
</tr>
页面B的部分代码:
<script language="Javascript" >
function sendValue(s){
var p = s+ " " +"<input type='hidden' name='<%=fvalue%>' value='" + s + "' >"
window.opener.document.getElementById('<%=fspan%>').innerHTML= p;
window.opener.document.getElementById('<%=fvalue%>').value = s;
window.close();
}</script>
<body class="body">
<b><%=flabel.getProperty("select_s")%><br><%=flabel.getProperty("select_user")%></b>
<%
for(String uid= (String)un.readByFirst(); uid!=null; uid=(String)un.readByNext()){
%>
<a href="javascript:sendValue('<%= uid%>')" > <%=uid%></a><br>
}
</body>
注意:
如果在IE下面,即使无:
<input type="hidden" name="ADMINUID" id="ADMINUID">
window.opener.document.getElementById('<%=fvalue%>').value = s;
在页面C调用:request.getParameter("ADMINUID")的时候,是有值的
但是在FireFox中则不行,原因是: innerHTML是IE专有的,所以在FireFox下面无法正常使用.所以需要在页面B的返回返回代码中加入:window.opener.document.getElementById('<%=fvalue%>').value = s;
但还有一些疑问:
1)为什么使用window.opener.document.getElementById('<%=fspan%>').value = s,页面A就无法捕捉到 <span id='adminuid' ><%= db.getAdminUID() %></span>?
2)如果使用window.opener.document.getElementByName('<%=fvalue%>').value=s,页面A也无法捕捉到ADMINUID的值呢?好奇怪呢!
本文转自kenty博客园博客,原文链接http://www.cnblogs.com/kentyshang/archive/2007/05/29/764037.html如需转载请自行联系原作者
kenty