RSS feed logo RSS Feed | About Pantz.org
Window control with Javascript
Posted on 11-02-2002 21:13:00 EST | Updated on 11-02-2002 21:13:00 EST
Section: /software/javascript/ | Permanent Link

Different code examples on how to control windows with Javascript.

Put all of the code examples from the links below between these script tags.

<script language="JavaScript">
<!--

//-->
</script>

Close a window from a link or checkbox (or button,etc).

<input type="checkbox" name="checkOne" onClick="window.close()">

<a href="close.shtml" onClick="window.close()">click here to close window</a>

Open a window.

window.open('whatever.shtml','whatever','width=300,height=610,resizable=no,scrollbars=yes');

On window open bring to top and in front.

<BODY onBlur="self.focus()"> <body>

This redirects an html document or link back to the page that a pop window opened from. Then closes the popup.

  function DoStuff() {
    opener.location.href = 'foo.shtml';
    window.close();
  }

Del.icio.us! | Digg Me! | Reddit!

Related stories