Randomly Display an Adversal Popup

Discussion in 'JavaScript' started by chatmasta, Dec 1, 2006.

  1. #1
    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 -->
    
    Code (markup):
    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
     
    chatmasta, Dec 1, 2006 IP
  2. ajsa52

    ajsa52 Well-Known Member

    Messages:
    3,426
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    160
    #2
    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 );
    
    Code (markup):
     
    ajsa52, Dec 1, 2006 IP
  3. chatmasta

    chatmasta Peon

    Messages:
    693
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    0
    #3
    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>
    Code (markup):
    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...
     
    chatmasta, Dec 1, 2006 IP
  4. ajsa52

    ajsa52 Well-Known Member

    Messages:
    3,426
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    160
    #4
    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 -->
    
    Code (markup):
     
    ajsa52, Dec 2, 2006 IP
  5. chatmasta

    chatmasta Peon

    Messages:
    693
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks dude, it worked.
     
    chatmasta, Dec 2, 2006 IP