Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Closing a Javacript Window

Posted on 1997-12-19
5
Medium Priority
?
305 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 2

Accepted Solution

by:
rigansen earned 600 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

705 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