Forum Moderators: open

Message Too Old, No Replies

Math.floor

         

kwery

7:45 pm on Apr 7, 2004 (gmt 0)

10+ Year Member



Hello,
I am trying to make this code work but doesn`t seem to make it. What i want it to do is to call a page once in two try by a user.
here`s my code:
sondage();

function sondage(){
var nbFoisNum = 1;
var surNum = 3;
var rndNum;
rndNum = Math.floor(Math.random()*surNum);
if ( rndNum <= nbFoisNum ){
//Local Variable Decleration
OpenPopup();
}
}

function OpenPopup() {
openpopup = window.open("https://ipsvr03.iperceptions.com/popup/webpopupC52F.asp","popupwin","width=400,height=435,left=0,top=10,resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes");
}

thank you very much

ajkimoto

2:46 pm on Apr 8, 2004 (gmt 0)

10+ Year Member



kwery,

If you want to work on a probability basis (on average one out of two times the popup window will fire), then you can use code like this:

function myRandom(){
var seed=10
output=Math.floor(Math.random()*seed)
if(output<=4){
OpenPopup();
}
}

If, on the other hand, you want it to pop up exactly, setting and retrieving a cookie might be a better way.

Hope this helps,

ajkimoto

Rambo Tribble

2:51 pm on Apr 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



And the point of frustrating your user is?

ajkimoto

3:17 pm on Apr 8, 2004 (gmt 0)

10+ Year Member



Looks like they want the users to take some kind of survey. I agree that this may not be the best way to 'encourage' users to do so, but hey, at least the code works!

ajkimoto