Solved

Closing a Javacript Window

Posted on 1997-12-19
5
283 Views
Last Modified: 2008-02-01
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
Comment
Question by:ssteeves
  • 3
  • 2
5 Comments
 
LVL 2

Accepted Solution

by:
rigansen earned 150 total points
ID: 1277003
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
 
LVL 2

Expert Comment

by:rigansen
ID: 1277004
if you replace:

   opener.frame3.location = newLink;

with

   opener.parent.frame3.location = newLink;

it'll work better... :)
0
 
LVL 1

Author Comment

by:ssteeves
ID: 1277005
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
 
LVL 2

Expert Comment

by:rigansen
ID: 1277006
ssteeves,
in closeWindow replace:

opener.frame3.document.location = ...

with

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

good luck!!
0
 
LVL 1

Author Comment

by:ssteeves
ID: 1277007
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now