Solved

Closing a Javacript Window

Posted on 1997-12-19
5
302 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 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

739 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