You can't do THAT on the web...or can you?

Posted Monday, December 15, 2003 1:28 AM by G Andrew Duthie

Peter Brunone, in his latest article on ASPAlliance.com, shatters a commonly-held belief of web developers...that you can't use script to close a browser window you didn't open using script:

The Uncanny Disappearing Window

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.

Did you know that ASPAlliance.com has an RSS feed? Now you do. That's how I found this article, and I'm glad I subscribed.

[Listening to: Agent Orange - Depeche Mode - Strangelove [#2] (05:08)]
Filed under:

Comments

# re: You can't do THAT on the web...or can you?

Monday, December 15, 2003 8:46 AM by AndrewSeven

Is that a bug that should be submitted to the IE team?

You should not be able to close a window you didn't open.

# re: You can't do THAT on the web...or can you?

Monday, December 15, 2003 8:52 AM by G. Andrew Duthie

If it's a bug, it's a bug that exists in most browsers, given the list of browsers that Peter claims this works on, which includes all the majors (IE, Netscape, Mozilla, Opera, and Safari).

# re: You can't do THAT on the web...or can you?

Monday, December 15, 2003 9:04 AM by AndrewSeven

So anywhere you can put this, you can close the browser?

<script language=javascript>
alert('are scripts filtered?')
</script>

# re: You can't do THAT on the web...or can you?

Monday, December 15, 2003 9:20 AM by G. Andrew Duthie

Sure looks that way, based on my testing. Guess that makes it all the more important to protect your apps from cross-site scripting attacks, doesn't it?

# .NET Nightly 71

Monday, December 15, 2003 9:18 PM by TrackBack

Leave a Comment

(required) 
(required) 
(optional)
(required)