Javascript across two windows

What I need to do is as follows:
One window Opens a different window when someone hits a link. I then want the second window to make the first window relaod (refresh) and close itself. I've been able to do everything except get the first window to reload itself. How do I do this?
LVL 1
adinasAsked:
Who is Participating?
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.

knightEknightCommented:
Try this:
In the child window, you can get the parent to reload itself like this:

<SCRIPT language='javascript'>
if ( self.opener && !self.opener.closed )
   self.opener.location=self.opener.location.href;
</script>
0
adinasAuthor Commented:
OK. It didn't work for me. I will show what i have on each page:

x.htm
------
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY ONLOAD="alert('hello')">

<FORM action="x1.htm" method=POST id=form2 name="LangCombo" target="xx">
      <INPUT type="submit" value="Submit" id=submit1 name=submit1>
</FORM>

<P>&nbsp;</P>

</BODY>
</HTML>

x1.htm
-------
<HTML>
<HEAD>
</HEAD>

<body ONLOAD="x()">
<script>
function x() {
      if ( self.opener && !self.opener.closed ) self.opener.location=self.opener.location.href;
      window.close();
}
</script>
</body>
</html>

Is there somthing I need to change?
0
knightEknightCommented:
Ah, when you said it opened another window, I assumed it did so via javascript.  Try this then:

in x.htm:

<SCRIPT language='javascript'>
 self.name='xyz';
</script>

then in x1.htm:

function x()
{
   var winxyz = window.open('','xyz');  // get a handle to xyz
   winxyz.location=winxyz.location.href;
   self.close();
}

0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

adinasAuthor Commented:
OK. Great it worked. Just post it as an answer and i will give you the points.

BTW is there anyway i can get IE not to ask the user if they want to close the window?
0
Michel PlungjanIT ExpertCommented:
No. If the history array holds more than one entry, the warning will appear - thanks for that. I hate it when people try to close my browser window.

Michel
0
adinasAuthor Commented:
well, I'm opening the window for a specific reason and want to close it immedeatly. I don't even want the user to notice that it opened!
0
Michel PlungjanIT ExpertCommented:
Hmm - should not give a warning then.

In v4 browsers you can do this instead:

<FORM action="x1.htm" method=POST id=form2
name="LangCombo" target="xx">
<INPUT type="submit" value="Submit" id=submit1 name=submit1>
</FORM>
<IFRAME NAME="xx" WIDTH=1 HEIGHT=1 SRC="about:blank">
<LAYER NAME="xx" WIDTH=1 HEIGHT=1 SRC="about:blank">
</LAYER></IFRAME>

and use parent.location.reload(1); // 0 if from cache is ok

Michel
0
adinasAuthor Commented:
well, in IE5 it worked great. perfetly. But when i loaded the page in Netscape 4.7 I got an alert: Alert! did not find a converter or decoder

when i closed the alert and hit the submit button a new window opened and kept refreshing itself over and over. I tried it on someone elses pc using Netscape 4.6 and the same thing happened!
0
knightEknightCommented:
Sorry, I am not familiar with the other problem you are having.
0
knightEknightCommented:
in x.htm:

<SCRIPT language='javascript'>
  self.name='xyz';
</script>

then in x1.htm:

function x()
{
   var winxyz = window.open('','xyz');  // get a handle to xyz
   winxyz.location=winxyz.location.href;
   self.close();
}
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
Michel PlungjanIT ExpertCommented:
Hmmm - very strange.

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