Reputation: 45
<div id="id1" runat="server">Open Windows</div>
<AjaxControlToolkit:PopupControlExtender ID="PopEx" runat="server" TargetControlID="id1" PopupControlID="Panel1" Position="Top" />
<asp:Panel ID="Panel1" runat="server">
<div> this text will show in the window that will open when the user clicks on 'OpenWindow' </div>
</asp:Panel>
How do I get a reference to the window that will open and then close it?
Upvotes: 0
Views: 638
Reputation: 1990
I name all of the windows that I open, then if I want to close it I have a file close.html that basically has
<html>
<head>
<script type="text/javascript">self.close()</script>
</head>
<body>
</body>
</html>
Then whenever I want to kill an open window, if I know the name, I can call:
window.open(<window name>, 'close.html');
A little hacky, but it works - especially if you're only using one window at a time.
Upvotes: 0
Reputation: 1469
To open and close the window from the main window, assign your command to a variable.
var newWindow = window.open("...");
// do something
newWindow.close();
Or if you are needing the new window to close via a link in the new window, try something like:
<a href="self.close()">Close</a>
Upvotes: 1