ASP page, closing a window with JavaScript

by "Craig" <cd-ml(at)aardvark.net.au>

 Date:  Thu, 22 Aug 2002 02:16:26 +0930
 To:  <hwg-techniques(at)hwg.org>
  todo: View Thread, Original
Hi,

Can you close a window with JavaScript after the page changes (for lack of a
better word)?

I have the ASP page below (watch the word-wrap). It simply opens a new window
when the 'open' button is clicked, and tries to close it with the 'close'
button. The 'open' button is a submit type which submits the form.  I've tried
to simplify the page and remove anything that's not related.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<script language="javascript">
 <!--
 function UploadStatus() {
  var w = 480, h = 340;
  //if (document.all || document.layers) {
     w = screen.availWidth;
     h = screen.availHeight;
  //}
  var popW = 150, popH = 150;
  var leftPos = (w-popW)/2, topPos = (h-popH)/2;
  UploadStatus =
window.open('page.htm','UploadWindow','scrollbars=no,status=no,width=' + popW
+ ',height=' + popH + ',top=' + topPos + ',left=' + leftPos);
 }
 function CloseUpload() {
  UploadStatus.close();
 }
 //-->
</script>
<%=request.form("open")%>
<form action="test.asp" method="post">
<input type="submit" value="open" name="open" onclick="UploadStatus();">
<input type="button" value="close" onclick="CloseUpload();">
</form>
</body>
</html>

Thanks,
Craig.

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA