Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Window opening using same URL automatically

Status
Not open for further replies.

Jimuniguy

Technical User
Mar 6, 2002
363
GB
Hi,

Ok, this is what I want to do:

Window opens with a URL, i want to be able to open up a new window with the same URL, at the same time closing the old one.

Any ideas?

Thank you in advance.
 
And oh I forgot, do all the above automatically with out user interaction.

Again Thanks
 
var x = location.href;
window.open x,'mywindow','width=400,height=200');

You may need parent.location.href depending upon your page setup


 
How do you stop this from continuing on ad infinitum? Each time you open the new window with the same URL, it'll have the same Javascript code to open a new window and close the old one. So, it'll open a new window, same URL, and close itself, while the new window is doing the same thing, etc. You'll need to pass some parameter in the URL to get it to stop after the first cycle.
 
Ok, thanks for that bit of coding, I have it now below:

<html>
<head>
<script>
function jim()
{
if (document.body.ClientWidth != 380)
{
var x = location.href; window.open(x,'mywindow','Width=400,height=400');
}
}
</script>
</head>
<BODY onload=&quot;jim()&quot;;>
</body>
</html>

This opens up a new window, but as TROLLACIOUS points out, it just keeps on cyling through it. I tried to use the IF command above, but it keeps doing it, so questions are:

A) Is it the orignal page making it recycle itself or is it the newly opened one which is doing it.

B) How do I stop it Cycling through itself as that if command does not want to stop it.

Thanks in advance
 
Ok, thanks for that bit of coding, I have it now below:

<html>
<head>
<script>
function jim()
{
if (document.body.ClientWidth != 380)
{
var x = location.href; window.open(x,'mywindow','Width=400,height=400');
}
}
</script>
</head>
<BODY onload=&quot;jim()&quot;;>
</body>
</html>

This opens up a new window, but as TROLLACIOUS points out, it just keeps on cyling through it. I tried to use the IF command above, but it keeps doing it, so questions are:

A) Is it the orignal page making it recycle itself or is it the newly opened one which is doing it.

B) How do I stop it Cycling through itself as that if command does not want to stop it.

C) How do I close that other window (espically since its the same as the new window, I think i need lots of IF commands here!)

Thanks in advance
 
Solved, but here is how I did it:

function jim()
{
if (self.name == 'mywindow')
{
}
else{var x = location.href;
window.open(x,'mywindow','width=400,height=200'); self.close();}
}

</script>



</head>
<BODY onload=&quot;jim()&quot;;>

Cheers everyone
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top