Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to close a Web Browser Window

Status
Not open for further replies.

DPROMICS

Technical User
Nov 5, 2003
108
US
I have a web page on which there are months of the year. The user clicks on a month which causes a new web window to open that displays that month's on call schedule.

The new web window is opened by:

<a HREF="/HV_staff_webpage_jan_oncall_schedule.html" target="_blank">

OK. I would like the user to be able to click on a link on the web window with the on call schedule by clicking on "Close". How can I close the web window opened to display the month's on call schedule using HTML code?

Assuming that is possible. It is not necessary that control is passed back to the original web window because the user will have to click on something else on that web window's web page anyway.

Best Regards,
 
needs to be asked in the javascript forum but,

Code:
<a href="javascript:window.close()">Close</a>

if by "the on call schedule" you mean onclick event then,

Code:
<a href="#" onclick="window.close()">Close</a>

or, if that gives you a confirm message use,

Code:
<a href="#" onclick="window.opener=null;window.close()">Close</a>

if this is what you mean ?
 
OK. Do I need any other "Java" code in the HTML document?
I haven't done much with Java . . . yet.

One would think that if there is a HTML command to open a new window from a displayed web page,

i.e. HTML commnand: target="_blank"

then there would also be a command to close a window.

Arrrrrg, inconsistencies and lack of logical thinking in "standards".

Thanks, Best Regards.
 
Not Java, Java[red]script[/red]. They're 2 completely different languages, and if you mix them up, your page REALLY won't work.

Being a markup language rather than a programming language, HTML doesn't have "commands", so there is no "command" to close a window using HTML.

Lee
 
OK. I tried this one. Which is what I had in mind. Worked as desired.

CODE
<a href="javascript:window.close()">Close</a>

Thanks.

Best Regards,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top