Forum Moderators: open

Message Too Old, No Replies

Javascript Popup box

         

andrewsmd

7:02 pm on Apr 23, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I would like to display a popup box on a link click that allows the user to select what page he/she goes to. The pseudo is something like this

<a href = "#" onclick=chooseSite(url1,url2);>go</a>

Then the JS pseudo would be like this
chooseSite(url1,url2){

//display a popup box with
//the choices site1 or site2

if(they clicked site1){

//redirect to site1

}//if

else{

//redirect to site2

}//else
}//chooseSite

Thanks

whoisgregg

3:46 pm on Apr 28, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Unfortunately, there are only two kinds of native Javascript pop-ups, the alert and the confirm. The confirm has two buttons ("OK" and "Cancel") but you can't override the labels on those buttons.

What you could do is have an absolutely positioned div that appears with the two options. There are a lot of options for this type of script, just look for a "lightbox script" that supports HTML and you should be able to get it working the way you want.

You *could* even style it to look like a pop-up (although you'll have to sniff the browser and OS to make sure you fake the right chrome).