The Uncanny Disappearing Window

December 16, 2003 12:41 by admin

How do you programmatically close a browser window when you didn't open it? Of course, everybody knows you can't. If they don't know that, they're novice developers and some seasoned veteran will set them straight... gently or otherwise.

Well, this week one of my clients -- whose intranet app opens in a specially formatted window -- told me they didn't want two windows just to start one application. I had very little success removing the toolbars from an existing window, and my vast web development experience told me that I had no other option. Rather, I didn't until a suggestion from a fellow member of the LaTech JavaScript list altered my perspective and resulted in the script I'm about to show you.

All you need to start the magic is to assign a window to the opener property of the current window. If this attribute is not set, the browser will realize that the current window is not open to your manipulation and nothing will happen.

      <SCRIPT LANGUAGE="JavaScript">
            window.opener = top;
      </SCRIPT>

[Read more]


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Javascript Trick

December 12, 2003 01:00 by admin

Did you know that you can execute javascript statements against a web page, just like using the Immediate window in Visual Basic 6? I just learnt this today.

Browse to a web page that has a disabled textbox and type this (replace the form and textbox names) in the address bar and hit enter.

javascript:void(document.Form1.txtBox1.disabled = false)

Presto you have an enabled textbox! Think of all the fun you can have on web sites that only have client side validation?


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5