Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pop ups

Status
Not open for further replies.

don320

Programmer
Apr 8, 2005
11
US
I need to create a pop up that will alternate pop-ups each time someone visits the site. Meaning, if I have 5 different pop-ups, I need it too start with popup[0], then popup[1] on the next visitor and so on.
var popup=new Array();
popup[0]=new Array("popup[1]=new Array("popup[2]=new Array("popup[3]=new Array("popup[4]=new Array("var winprops = "width=400, height=430,location=no,toolbar=no,menubar=no,scrollbars=no,resizeable=yes";
exited = 1;
can anyone help?
 

If it is to be random per visitor, then you will need to use server-side scripting.

Do you have any server-side scripting available to you (ASP, JSP, PHP, CFM, etc)?

Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
Yes I do. Do you know of a place to find some samples of similar scripts that might work?
 

Try the forum for whichever scripting you are using. You've not said which it is, so I can't really give you any pointers, can I?

Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
I guess that's the problem. I have made pop-ups, and random pop-ups, but I have never created a pop-up that will alternate per visit and is server-based before. So, I'm not sure which code to write it in. I was hoping for some direction which would be the best to start with.
 
Which would be the best to create a pop-up that alternates per visit in asp, php or cold fusion?
 

You know... if you look at this statistically... you serve 100 hits to a page. You have 5 banners and so ideally after 100 hits you would like to have delivered each banner 20 times.

If you want to go for a server solution - you can use anything. I would suggest PHP because the syntax is remarkably similar to Javascript (and it's really easy once you get into it). You might save a file in a special place that a PHP script can access... read the number you saved in there... increase it by one (and modulus it as needed of course)... write the file... deliver the number to the page. This very same approach would work in ASP and JSP (that I can confirm).

If you decide to go with a Javascript solution (that isn't exactly what you were looking for -- but statistically it is *lol*)...

Instead of tracking the banner that was last viewed etc (which, as Dan suggests, is something you would do server-side) you could select one of the 5 banners randomly on page load.

The following code builds on your existing popup array and winprops variable. I'm sure it's enough to get you started.

Code:
<script type="text/javascript">
// ... your popup array definition and assignment goes here
// ... your winprops assignment goes here

var myBannerIndex = Math.floor(Math.random(100)*popup.length);
var myPopup = window.open(popup[myBannerIndex][0], popup[myBannerIndex][1], winprops);
</script>

Cheers,
Jeff

 

It really depends what your hosting company offers. As Jeff says, any language can do this. Whichevere you are most comfortable with, or have most ease finding a host for, will do.

You pick whichever you want.

Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top