Forum Moderators: open
Can anyone please let me know the exact change to the code below, to make it appear every 1 in 10 visits please.
Sev.
<script Language="JavaScript">
<!--
sondage();
function sondage(){
var nbFoisNum = 1;
var surNum = 10;
var rndNum;
rndNum = Math.floor(Math.random()*surNum);
if ( rndNum <= nbFoisNum ){
//Local Variable Decleration
OpenPopup();
}
}
function OpenPopup() {
openpopup = window.open("U R L à insérer ","popupwin","width=400,height=435,left=0,top=10,resizable=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no");
}
// -->
</SCRIPT>
First appearing question is: does the popup need to come up every 10 visits of one and the same visitor, or every 10 visits, no matter who that is?
If it's 10 for one visitor then the answer lays in storing the visit info in cookie. If it's for all then you need some onserver script language, eg. php, or cgi to store the info in the file, or database.
However to say the truth I would go on with the function you wrote above, because it works quite good, and saves really a lot of effort.
Best wishes!
Michal Cibor
This script does the basics for you.
[cookiecentral.com...]
Just take the numbers and use the modulus operator.
if you were me, would you go the cgi route please?
If I were you, I'd know your reasons and priorities, so that's a tough one.
If I were me, however, I would use the cookie route. I'd put up with the fact that it didn't work with that 5%, but maybe have a default mechanism that launches a popup at random with 10% probability when cookies are disabled.
The trouble with any CGI approach is that you can only count visits in general, not visits per individual.
- That is unless you are keeping a database of IP addresses/visits, which itself is made unreliable by network complexities like PAT and DHCP anyway (...probably!).
"The trouble with any CGI approach is that you can only count visits in general, not visits per individual."
As mentioned, I would want it to count general visits, not individuals, so I assume that in this case cgi would be good?
Many thanks for the link Michal, I'll take a look there as well.
Sev.