我的查詢是,註銷後關閉所有子窗口(如果打開)。 我從不同的jsps創建子窗口&我想從Search.jsp關閉它。 Search.jsp具有創建,註銷等按鈕。如何在Javascript中通過名稱獲取窗口對象?
我search.jsp的是 -
<%
String sessionstart = (String)session.getAttribute("sessionstart");
if(sessionstart != null)
{
%>
<body>
<div align="center" > <img src="images/Headerimage.png" alt=""> </img></div>
<div id = "leftmargin" >
<form action="Search" method="post">
<table cellspacing="10" cellpadding="10">
<tr >
<td >Type</td>
<td><input type="text" name="type" value="*" required /></td>
<td> Name</td>
<td><input type="text" name="name" value="*" required /></td>
<td> Description</td>
<td><input type="text" name="description" value="*" required /></td>
<td></td><td></td>
<td><input type="submit" value="Search" /></td>
<td>
</td>
<td><h5> <input type="button" value="Create" onclick="Create();" /></h5> </td>
<td> <h5> <input type="button" value="Logout" onclick="Logout(); " /> </h5> </td>
</tr>
</table>
</form>
</div>
<%
if (sessionset != null) {
%>
<div align="center" style="margin-top: 15%">
<img src="images/DocumentManagementSplash.png" alt=""> </img>
</div>
<%
}
%>
</body>
<%
}
else
{
%>
<script>
window.location.replace("ietmLoginDialog.jsp");
</script>
<%
}
%>
<script type="text/javascript">
function Create() {
window.open("ltIEnterCreatePartFileUpload.jsp?", "CreatePart",
"height=140,width=350");
}
function Logout() {
var w = document.getElementsByName("mywin");
alert("w closed :: "+ w.closed);
alert("w name :: "+ w.name);
alert("w open:: "+ w.open);
if(w.name == "mywin"){
w.close();
}
window.open("ietmLoginDialog.jsp", '_self', "location=yes");
}
</script>
這裏,如果我在註銷按鈕點擊,那麼它必須關閉所有打開的子窗口。 我從不同的jsp創建的childs窗口。 例如,從search.jsp的,我打開屬性頁即,
<td style="width: 170px;" ><a
href="ltSearchDocProperties.jsp?idvalue=<%=strObjectId%>"
onclick="window.open(this.href, 'mywin',
'left=20,top=20,width=900,height=725'); return false;"><%=strName%></a></td>
從Property.jsp,我打開編輯JSP即,
<h5 align="right">
<a href="ltSearchDocEdit.jsp?idvalue=<%=strObjectId%>" onclick="window.open(this.href, 'mywiirn','width=900,height=615,resizable=false'); return false;">Edit</a> </h5>
&同樣。 據我所知,我可以實現這一點,如果我從相同的jsp即創建子窗口即。僅限Search.jsp。
我的讀數 -
How to close all the child pages on LogOut
How to Close multiple child windows from a parent window
這再次說明只有在窗口引用是唯一的JSP。 所以請建議我,我如何關閉所有子窗口,從另一個jsp(Search.jsp)創建不同jsp的 ?
任何建議或任何其他方式來實現這一目標,將對我非常有幫助。
在此先感謝。
應刪除Java標記。 Java與JavaScript無關。 –
@HowardRenollet - 你是對的,一定是星期一布魯斯:-)通常我只是留下評論...(Downvote and comment undone) –
@GyroGearless - 謝謝。我的評論也被刪除了:)祝你有一天好好休息! –