Expekt bonuses - Submit articles - Debt Consolidation - Wordpress Themes - Bob's Free Stuff Forum

PDA

View Full Version : Randomly Display an Adversal Popup


chatmasta
Dec 1st 2006, 2:17 pm
I was given this code for adversal.

<!-- Begin Publisher Code -->
<script src="http://www.adversalservers.com/publisherJS.js"></script>
<script type="text/javascript" language="javascript">
initAdversal("8f92b13db33e4e432fe11e4466c5aabb", true);
</script>
<!-- End Publisher Code -->


This displays a full page popup. However, I want to only display it randomly, say a 1 in 10 chance.

I would appreciate a code snippet that accomplishes this. The trouble I am having is that I can't randomly display a whole block of javascript like this.


Thanks

ajsa52
Dec 1st 2006, 3:22 pm
I don't know Adversal Popups, but you can get a random number between 0 and 9 with something like this:

var myRandom = Math.floor( Math.random()*10 );

chatmasta
Dec 1st 2006, 7:27 pm
Yeah I realize that, and I got this far.

<script language="javascript" type="text/javascript">
var ran_number=Math.floor(Math.random()*2);
if(ran_number == 1) {

}
</script>

But I can't put the code snippet adversal gave me in the if statement because it requires script tags. Mess around with it and see if you can get it to work, because I can't...

ajsa52
Dec 2nd 2006, 2:44 am
Try this:


<!-- Begin Publisher Code -->
<script src="http://www.adversalservers.com/publisherJS.js"></script>
<script type="text/javascript" language="javascript">
var ran_number=Math.floor(Math.random()*2);
if(ran_number == 1) {
initAdversal("8f92b13db33e4e432fe11e4466c5aabb", true);
}
</script>
<!-- End Publisher Code -->

chatmasta
Dec 2nd 2006, 11:45 am
Thanks dude, it worked.