Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 307
  • Last Modified:

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.

0
ssteeves
Asked:
ssteeves
  • 3
  • 2
1 Solution
 
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
 
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now