closing a window on a webpage with javascript

I have this bit of code on an exit button on a webpage

<div style="position:absolute; left:690; top:3; cursor:hand;">
<a href="JavaScript:window.close()">
<img src="exit_course_n.gif"  onMouseOver="src='exit_course_o.gif'"
onMouseOut="src='exit_course_n.gif'"  border="0" >
</a>
</div>

This works fine to close the window when you first come into it. HOWEVER the html page opens another html page in that window when I click a "go to" button. On this new page there is a "return to menu" button which opens up the original webpage in that window again. So all in one window, no new window. When I am back on the original webpage, the window.close above code ^^ doesn't work. I tried self.close as well - same problem. Could anybody give me some code that would work?

thanks.

RupertAAsked:
Who is Participating?
 
hieloConnect With a Mentor Commented:
My guess would be:
<div style="position:absolute; left:690; top:3; cursor:hand;">
<a href="#" onclick="JavaScript: top.close();return false;">
<img src="exit_course_n.gif"  onMouseOver="src='exit_course_o.gif'"
onMouseOut="src='exit_course_n.gif'"  border="0" >
</a>
</div>

Open in new window

0
 
erikTsomikSystem Architect, CF programmer Commented:
can you post more code here
0
 
hieloCommented:
>> the html page opens another html page in that window when I click a "go to" button
Are you working with frames?
0
 
cb1393Commented:
Just a shot in the dark without seeing more of your code, but maybe try something like the following...
<div style="position:absolute; left:690; top:3; cursor:hand;" onClick="JavaScript:window.close()">
<img src="exit_course_n.gif"  onMouseOver="src='exit_course_o.gif'"
onMouseOut="src='exit_course_n.gif'"  border="0" >
</div>

Open in new window

0
 
scrathcyboyCommented:
<BODY onUnload = "parent.close();widow.close()">  works for me.
0
All Courses

From novice to tech pro — start learning today.