Page 1 of 1

Popup

Posted: Sat Sep 06, 2008 4:24 pm
by adaywalkr
Hello,

I've stumbled upon 2 Javascript issues when making a small pop-up function. The pop-up is just like the one Newgrounds has; the background get's darkened and the content is in a div.

Now I couldn't figure out how to center (vertical and horizontal) the div with content. The div can't be centered by using margin, since it's position is absolute. I guess this would need to be done with Javascript.

The second problem is that setTimeout in Internet Explorer doesn't work like the rest of the browsers, you can't pass arguments to functions you call.. I've searched around a little bit and haven't found a solution. The problem is that I use a for-loop

Code: Select all

    for (i=1; i<=100; i++) {
        setTimeout(show_popup,i*4,i);
    }
This doesn't work in IE, because I need to pass argument i to the function show_popup. I have tried several other methods but failed.

Thanks in advance

Re: Popup

Posted: Wed Sep 10, 2008 10:42 am
by Darkzaelus

Code: Select all

 
position:absolute;
left:50%;
margin-left:1/2width;
 
etc...

Code: Select all

 
for (var i=1; i<=100; i++) {
        setTimeout(show_popup,i*4,i);
    }
 
With javascript you have to initialise variables before you can use them.

Cheers, Darkzaelus