[thelist] Closing a window with JavaScript

Craig cd-ml at aardvark.net.au
Wed Aug 21 10:40:01 CDT 2002


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.






More information about the thelist mailing list