-
June 7th, 2012, 06:33 PM
#1
Waiting till page is loaded
I hope someone can help me with a small problem. I have a javascript which shall open some external links in a new window.
My current problem is that the next link shall be only opened when the one before is loaded completely
Code:
my_window1 = window.open('http://URL1...','_blank',"status,height=600,width=800");
// -> wait till Window is loaded and then continue with the next line
my_window2 = window.open('http://URL2...','_blank',"status,height=600,width=800");
// -> wait till Window is loaded and then continue with the next line
my_window3 = window.open('http://URL3...','_blank',"status,height=600,width=800");
// -> wait till Window is loaded and then continue with the next line
my_window4 = window.open('http://URL4...','_blank',"status,height=600,width=800");
How can I do this?
-
June 7th, 2012, 11:38 PM
#2
Re: Waiting till page is loaded
Use the onload event for the current window to load the next window.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
June 8th, 2012, 01:48 AM
#3
Re: Waiting till page is loaded
I can't because the new called websites are external websites which I can't change. Is there a way that I can ask the new window if it's finished with loading and stop the script in the main page till then?
-
June 8th, 2012, 09:55 AM
#4
Re: Waiting till page is loaded
Yes, you can. Being from a different domain has nothing to do with it.
Code:
var winGoogle = window.open("http://www.google.com","google","status,height=600,width=800");
winGoogle.onload = function () {
alert("All done!");
}
Last edited by PeejAvery; June 8th, 2012 at 05:31 PM.
Reason: Fixed spelling
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
June 8th, 2012, 03:16 PM
#5
Re: Waiting till page is loaded
-
June 9th, 2012, 07:48 AM
#6
Re: Waiting till page is loaded
Ok I tried this but it's opening only one page which won't be closed automatic. What is wrong? I would have expected this: Opening window 1, closing it when it's finished with loading and then opening the next one and so on
Code:
<script type="text/javascript">
my_window0 = window.open('https://url1....','_blank',"status,height=600,width=800");
my_window0.onload = function ()
{
my_window0.close ();
my_window1 = window.open('https://url2....','_blank',"status,height=600,width=800");
my_window1.onload = function ()
{
my_window1.close ();
my_window2 = window.open('https://url3....','_blank',"status,height=600,width=800");
my_window2.onload = function ()
{
my_window2.close ();
}
}
}
</script><br>
-
June 10th, 2012, 08:42 AM
#7
Re: Waiting till page is loaded
Since you're dealing with separate domains, some browsers will block it due to cross-domain script issues. There's nothing around that unless you control the browser usage.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|