First time writing in javascript, so I apologise for any obvious silly mistakes.
Im trying to write a javascript that once a link is pressed, a popup opens and a series of websites, with 2 changing parameters (from arrays), are loaded in series (after a time delay, or if possible once the page has loaded).
I have managed to get a working script together, but I can't seem to make it load within the same window, instead of loading several pages after each other.
So what I am asking really is, how do I ensure it loads within the same popup window? and If possible, how can I improve the code so that it only "pauses" untill the page is loaded instead of just waiting 10 seconds?
Thanks in Advance
Code:
<script type="text/javascript">
function makeCrankWindow(url)
{
crankWind = window.open(url,"Cwindow");
if (window.focus) {newwindow.focus()}
return false;
}
function Crankwindow()
{
var wid = []; //Titan Id Array
wid[0] = "53";
wid[1] = "57";
wid[2] = "194";
wid[3] = "196";
wid[4] = "242";
wid[5] = "286";
var sid = []; // Facebook Id Array
sid[0] ="5089"; // NAME HERE
var timeout = 0;
for (var i=0; i<2; i++)
{
for (var j=0; j<6; j++)
{
setTimeout('makeCrankWindow(\"http://apps.facebook.com/ageofchampions/gift_accept.php?source=190&sourceu=' + sid[i] + '&wid=' + wid[j] + '\","Cwindow")', timeout);
timeout += 10000;
}
}
}
</script>
Make crankWind global . If that doesn't work use location.href to change the location of sub window instead of making new window again and again. Assign a value of 1 to a global(say i). Place i++ inside makeCrankWindow function. Now check for if(i>1){use location.href }else {use window.open.}
Any problem post it here.
If You Are Good At Something, Never Do It For Free-joker
Bookmarks