Closing a Javacript Window

Hello.  I have a javascript problem, and I was wondering if anyone out
there may know a solution.

I use Javascript to open a window when I click a button.  That's easy.
The new window is a menu.  When you click a menu item I want to parent
window to go to that location, AND I want the window to close.   This is
the code I use in the Menu window that get's opened by Javascript:

<HTML>
<HEAD>
<SCRIPT>
  function closeWindow()
  {
      javascript:top.close();
  }
</SCRIPT>
</HEAD>
<BODY>
text goes here:

<CENTER><A HREF="javascript:top.close()"><IMG SRC =
images/close.GIF"></A>
<A HREF="indexnj.html" TARGET="frame3" onClick="closeWindow()"><IMG SRC
= "images/continue.GIF"></A>

</BODY>
</HTML>

So basically, if they hit the continue button I want the page to load,
and the new window to close.  If I take out the
onClick = "closeWindow()" it works, but the new window stays open.  Can
anyone see a solution?

Shane.

LVL 1
ssteevesAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

rigansenCommented:
use this code instead of yours:

<HTML>
<HEAD>
<SCRIPT>
function closeWindow(newLink)
{
   opener.frame3.document.location = newLink;
   self.close();
}
</SCRIPT>
</HEAD>
<BODY>
<CENTER>
<A HREF="javascript:self.close()"><IMG SRC = images/close.GIF"></A>
</CENTER>
<A HREF="javascript:closeWindow('indexnj.html')"><IMG SRC = "images/continue.GIF"></A>
</BODY>
</HTML>

any doubt or problem, just post it... ok!?

good luck!!

rigansen.
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
rigansenCommented:
if you replace:

   opener.frame3.location = newLink;

with

   opener.parent.frame3.location = newLink;

it'll work better... :)
0
ssteevesAuthor Commented:
It now gives me a javascript error.  It says

opener.frame3 has no properties.

I'll give you the URL to try it yourself if you want.  As you can
see, I'll increase the value of this question if you can solve it.

The following URL is where this problem is now.  We're experiencing a few minor server errors, so the bottom frame may not load the first time.  Just keep re-loading the bottom frame till it comes up.  When it comes up, there should be a number bar.  Click number 3, and then click Continue.  It should close the window, and change the background link.

http://207.247.105.204/directories/startnj.html

Good Luck, if you still wish to pursue this question.

0
rigansenCommented:
ssteeves,
in closeWindow replace:

opener.frame3.document.location = ...

with

opener.parent.frame3.document.location = ...

good luck!!
0
ssteevesAuthor Commented:
Thank you so much!  It works perfectly!  I wish you all the best, and here are all the points I have.  I'd give you more if I had them.  

Keep up the good work!
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
JavaScript

From novice to tech pro — start learning today.