Closed Thread Icon

Preserved Topic: opening new window after certain variable set true Pages that link to <a href="https://ozoneasylum.com/backlink?for=17946" title="Pages that link to Preserved Topic: opening new window after certain variable set true" rel="nofollow" >Preserved Topic: opening new window after certain variable set true\

 
Author Thread
grrr
Paranoid (IV) Inmate

From:
Insane since: Mar 2001

posted posted 05-04-2001 04:42

i would like to have a window popup after i have preloaded a number of images. so once the loading is complete, my variable, called 'imagesdone', is set to 'true'. could someone please help me with the bit of code needed to trigger the window opening. i understnad general if statements, but i have not been able to get it to work.

please help.

nephicheng
Nervous Wreck (II) Inmate

From:
Insane since: Feb 2001

posted posted 05-04-2001 06:49

i'm not exactly sure on if this is right or what but maybe try

if(image1 & image2 & image3 .......){
variable=true;
}

not sure what the test is to see if an image is preloaded

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 05-04-2001 08:34

okay here is my generic preloading script
/*********************************** Begin *****************************/
loaded = false
mywin = false
function preload() {

imgsrc = new Array;
imgsrc[1] = 'sexy_on.gif';
imgsrc[2] = 'sexy_off.gif';
imgsrc[3] = 'headshots_on.gif';
imgsrc[4] = 'headshots_off.gif';
imgsrc[5] = 'fashion_on.gif';
imgsrc[6] = 'fashion_off.gif';
imgsrc[7] = 'casual_on.gif';
imgsrc[8] = 'casual_off.gif';
imgsrc[9] = 'swimwear_on.gif';
imgsrc[10] = 'swimwear_off.gif';
imgsrc[11] = 'lingerie_on.gif';
imgsrc[12] = 'lingerie_off.gif';

imgs = new Array();
if (document.images) {
for (i=1; i < imgsrc.length;i++){
imgs[i] = new Image;
if (imgsrc[i] != "undefined") {
imgs[i].src = imgsrc[i];
}
}
}
loaded = true;
}

Now see that variable loaded? it starts out false and then turns true after everything is loaded.

so if I make an if statement it would look like this
if (loaded) {
window.open('www.whatever.com','win');
}

problem is that that would only get called once. and if it is false then no window.
so you could make function

function openWin() {
if (loaded) {
mywin = window.open('www.whatever.com','win');
}
// Now if the window isn't open I want this to wait a bit and try again thats why mywin is set false above
if (!mywin) {
setTimeout('openWin()',200);
}
}

Of course this is a bit complicated. I would just make it so that at the end of your preload function the your window opens. I don't know why you need to "check"
}





Walking the Earth like Kane

grrr
Paranoid (IV) Inmate

From:
Insane since: Mar 2001

posted posted 05-04-2001 15:46

thanks alot bitdamaged- exactly what i need! i'd been trying to do something similar and wasn't getting a window at all. i think it was probably as you had explained.

[This message has been edited by grrr (edited 05-04-2001).]

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 05-04-2001 21:46

The key here is placement.
Do you have the whole script?

The exclamation point means "not" or false.

so if (!mywin) means "if mywin is false" it's just shorthand. in JS if a variable is set to false, 0 (zero) or not set to anything (var mywin then this statement will parse true. thats a little confusing, mywin is false but the "if" statement (if mywin is false) is true.
Anyway as soon as we make mywin somehing (in this case a window object) it will parse true.


Anyway If you show me the code you are using I'll see where this can be fixed




Walking the Earth like Kane

« BackwardsOnwards »

Show Forum Drop Down Menu