View Full Version : how to close a browser window

10-17-2010, 08:58 AM

is there a way that I can close a browser window with some type of link inside this window? and not via its parent window?

i want to open a window and in it, have a question of yes or no and if a user answers 'no', i would like to close the window, but i can't seem to do so.

so my parent window has codes like this:

<head><title>test close html</title>
<link rel="stylesheet" href="windowfiles/dhtmlwindow.css" type="text/css" />

<script type="text/javascript" src="windowfiles/dhtmlwindow.js">

* DHTML Window Widget- Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code

this is a test html<br/><br/>
<a href="#" onClick="googlewin.hide(); return false">Hide Window 1</a><br/><br/>

<script type="text/javascript">
googlewin=dhtmlwindow.open("googlebox", "iframe", "http://localhost:8080/IRS1098t/test.html", "test closing a dhtml window", "width=700px,height=450px,resize=1,scrolling=1,center=1", "recal")


and my test.html looks like this:

<head><title>test html</title>
this is a test html to test closing of the dhtml window<br/><br/>

<a href="#" onClick="googlewin.hide(); return false">Hide Window 1</a><br/><br/>
<a href="javascript:googlewin.hide(); return false">Hide Window 1</a><br/><br/>
<A href="javascript:self.close()">Close this Window using self.close</A><br/><br/>
<a href="javascript:window.opener='x';window.close();">Close using window.opener</a>


as you can see, i'm trying several methods to close it but no luck.
any help would be greatly appreciated!
thank you.

10-17-2010, 10:23 AM
<a href="#" onclick="parent.googlewin.hide(); return false;">Hide Window 1</a>

10-18-2010, 01:06 AM
that didn't work. I think I confused you. I'm trying to click on a link (or a button) in the newly popup window to close itself, not via the parent window.

so test_close.html opens up test.html; and I need to have test.html closed when the user clicks on a link or a button.


10-18-2010, 02:12 AM
Please post a link to a page on your site that contains the problematic code so we can check it out.

10-28-2010, 07:09 PM
sorry for the late reply. It worked. I was not pointing to a valid place for the javascript.
thanks for helping me out!