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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
hieloCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
scrathcyboyCommented:
<BODY onUnload = "parent.close();widow.close()">  works for me.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.