Hi,
Does anyone know how I can close a browser page via VBScript code?

thanks

Re: Close Browser page by ASP by Scott

Scott
Mon Dec 22 10:41:49 CST 2003

"Rafael Chemtob" <rchemtobb@nospam.yahoo.com> wrote in
news:u37rICKyDHA.2576@TK2MSFTNGP09.phx.gbl:

> Does anyone know how I can close a browser page via VBScript code?

Hi Rafael,

There's a difference between ASP and VBScript - ASP is server-side only,
and it can incorporate the VBScript language... but it doesn't
necessarily have to. You can't close a browser window from the server,
therefore you can't use ASP to close it. You can use VBScript on either
the client- or server-side though. [sorry about the big description, but
it's important to separate ASP from VBScript - they're not the same
thing].

Anyway, here's a bit of code-snippet that demonstrates how to use
VBScript to close a window:

<html>
<head>
<title>Test Page</title>
<script language="VBScript">
Function CloseWindow()
window.close()
End Function
</script>
</head>
<body>
<input type=button name=ClickMe value="Click Me!"
onclick="CloseWindow()">
</body>
</html>

Re: Close Browser page by ASP by Bob

Bob
Mon Dec 22 10:43:55 CST 2003

Rafael Chemtob wrote:
> Hi,
> Does anyone know how I can close a browser page via VBScript code?
>
> thanks

ASP code executes on the server, so ASP code cannot be used to close the
browser.

You can use

window.close

to close the browser in client-side code, but the user will be prompted. In
many browsers, you can use

window.opener="me"
window.close

to close the browser without prompting the user, but more and more browsers
are closing this security loophole.

HTH,
Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"



Re: Close Browser page by ASP by Roland

Roland
Tue Dec 23 04:12:53 CST 2003

"Scott McNair" wrote:
> "Rafael Chemtob" <rchemtobb@nospam.yahoo.com> wrote in
> news:u37rICKyDHA.2576@TK2MSFTNGP09.phx.gbl:
>
> Anyway, here's a bit of code-snippet that demonstrates how to use
> VBScript to close a window:
>
> <html>
> <head>
> <title>Test Page</title>
> <script language="VBScript">
> Function CloseWindow()
> window.close()
> End Function
> </script>
> </head>
> <body>
> <input type=button name=ClickMe value="Click Me!"
> onclick="CloseWindow()">
> </body>
> </html>

Just to add a few relevant items:

language= is deprecated for client script so:
<script type="text/vbscript">

Since ASP runs on the server, it will support any browser. Client-side
vbscript is only supported by IE so should only be considered for Intranet.

Should you need to close a window on the Internet, then javascript should be
used:

<html>
<head>
<title>Test Page</title>
</head>
<body>
<span style="border: 2px outset #ddd; cursor: pointer; background-color:
#ccc" id=ClickMe onClick="window.close()">Click Me!</span>
</body>
</html>

--
Roland

This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose.



Re: Close Browser page by ASP by Gary

Gary
Tue Dec 23 21:03:09 CST 2003

> Just to add a few relevant items:
>
> language= is deprecated for client script so:
> <script type="text/vbscript">
>
> Since ASP runs on the server, it will support any browser. Client-side
> vbscript is only supported by IE so should only be considered for
Intranet.
>
> Should you need to close a window on the Internet, then javascript should
be
> used:
>
> <html>
> <head>
> <title>Test Page</title>
> </head>
> <body>
> <span style="border: 2px outset #ddd; cursor: pointer;
background-color:
> #ccc" id=ClickMe onClick="window.close()">Click Me!</span>
> </body>
> </html>

But, by this you are assuming that everybody does not use Windows/IE for
their internet experience. For shame!

> --
> Roland
>
> This information is distributed in the hope that it will be useful, but
> without any warranty; without even the implied warranty of merchantability
> or fitness for a particular purpose.
>
>



Re: Close Browser page by ASP by Roland

Roland
Wed Dec 24 05:11:40 CST 2003

"Gary Morris" wrote:
> But, by this you are assuming that everybody does not use Windows/IE for
> their internet experience. For shame!

Actually, I do but sometimes you have to humor them. You hear that Santa?

--
Roland

This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose.



Re: Close Browser page by ASP by hrothenb

hrothenb
Mon Jan 05 13:38:05 CST 2004

"Rafael Chemtob" <rchemtobb@nospam.yahoo.com> wrote in message news:<u37rICKyDHA.2576@TK2MSFTNGP09.phx.gbl>...
> Hi,
> Does anyone know how I can close a browser page via VBScript code?
>
> thanks

You can try:

Response.Write"<script
language=""Javascript"">window.opener=self;window.close();</script>"