HTML & WEB-Design

Moderators: Jonathan
Number of threads: 1253
Number of posts: 3360

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Close Button Posted by Omega99 on 15 Apr 2004 at 8:03 AM
I need to put a button on my page that closes the window. I need to do this either by using html or vb script. Does anyone know how to do this?

any help or sample code would be greatly appreciated,

Omega99
Report
Re: Close Button Posted by Weirdofreak on 15 Apr 2004 at 12:44 PM
You can't do it with HTML full stop, and if you don't want people like me annoyed with you for using VBscript, you can't do it with that either. It can be done with Javascript in a much more browser-compatible way, and I can't think of any reason you'd need to use VBscript specifically, at least not for something like this.

<form>
<input type="button" onclick="window.close();">
</form>

There'll be a confirmation box when they click, as a security measure (or something like that).
Report
Re: Close Button Posted by Jonathan on 15 Apr 2004 at 4:10 PM
: You can't do it with HTML full stop, and if you don't want people like me annoyed with you for using VBscript, you can't do it with that either. It can be done with Javascript in a much more browser-compatible way, and I can't think of any reason you'd need to use VBscript specifically, at least not for something like this.
:
: <form>
: <input type="button" onclick="window.close();">
: </form>
:
Agree. JavaScript is certainly the right tool for the job, and should be chosen over VBScript whenever possible. JavaScript is also a little less ugly than VBScript.

: There'll be a confirmation box when they click, as a security measure (or something like that).
:
I think this depends on who created the window. If you window.open'd it yourself, then calling window.close won't cause any upset (so far as I'm aware). It's when you close windows the user opened ("main" browser windows) that the messages appear.

That's the best model for the behaviour IE exhibits that I can come up with, anyway. Of course, we are talking IE here so internally it's probably more like...

if (rand() > 0.5)
    showCloseWindowWarning;




Jonathan

###
for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
(tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
/(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.