Popup

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
adaywalkr
Forum Newbie
Posts: 6
Joined: Fri Sep 05, 2008 7:30 pm

Popup

Post 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
Darkzaelus
Forum Commoner
Posts: 94
Joined: Tue Sep 09, 2008 7:02 am

Re: Popup

Post 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
Post Reply