Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Random number based PopUnder

    Hello guys,

    I'd like to know hoe to do a PopUnder window (to an URL) so, that it starts only randomly. for example every 20'th time someone loads the page.
    The frequency should be changeable, so it should be based on random numbers between 1 and n, so in case a visitor "get's" random number 20 for example, he'll get's a popunder window like "www.google.com", but if the visitor get's number 1´-n (not 20), no popunders appears.

    Thanks/
    Ekix
    Last edited by Ekix; 12-04-2006 at 12:14 PM. Reason: I used PopUp insteas PopUnder in the Title by mistake

  • #2
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts
    Code:
    <script type=text/javascript>
    var outof='20';
    randnumber=Math.round(Math.random()*(outof-1));
    randnumber++;
    if(randnumber=='1'){window.open('http://www.yahoo.com');}
    </script>
    the above will generate a random number between 1 and 20, and if the number is 1, it'll open up a window(popup).

    you'll need to decide what add to show them, and how big to make window , ect.....
    Last edited by brandonH; 12-04-2006 at 11:44 AM.
    I make no attempt at pretending like I'm a professional. I offer help with what knowledge I do have.

  • #3
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Some details more

    Thanks for your fast reply. Just one thing, I would like the window to appear as popunder instead pf popup. Is this possible?



    Thanks/
    Ekix

  • #4
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts
    sorry, went to go eat breakfast.

    </body>
    <script type=text/javascript>
    var outof='20';
    randnumber=Math.round(Math.random()*(outof-1));
    randnumber++;
    if(randnumber=='1'){
    var mypopup=window.open('');
    mypopup.blur();window.focus();

    }
    </script>


    that will bring focus to the main window(putting popup under it).
    the only thing is though, is some sites call focus to their window after the page is loaded, like yahoo.com . so if they call focus then the popup will come back on top.
    Last edited by brandonH; 12-04-2006 at 12:59 PM.
    I make no attempt at pretending like I'm a professional. I offer help with what knowledge I do have.

  • #5
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts
    and if you have multiple ad's that you want to be randomly displayed do as such:

    Code:
    <script type=text/javascript>
    var outof='20'; //chance of popunder opening
    var ads=new Array();
    ads[0]="http://www.yahoo.com";
    ads[1]="http://www.google.com";
    ads[2]="http://www.codingforums.com";
    ads[3]="http://www.pogo.com";
    //keep adding site addresses for more ads
    randAD=Math.floor(Math.random()*ads.length);
    randnumber=Math.round(Math.random()*(outof-1));
    randnumber++;
    if(randnumber=='1'){
    var mypopup=window.open(ads[randAD]);
    mypopup.blur();window.focus();
    
    }
    </script>
    Last edited by brandonH; 12-04-2006 at 01:46 PM.
    I make no attempt at pretending like I'm a professional. I offer help with what knowledge I do have.

  • #6
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hmm... thinking

    I could not get it working for some reason, and I'd just like to open 1 PopUnder (http://www.google.com) for example. Here's how I did it:

    <html>
    <head>
    <meta content="text/html; charset=ISO-8859-1"
    http-equiv="content-type">
    <title>PopUnder</title>
    </head>
    <body>
    <script type="text/javascript">
    var outof='20'; //chance of popunder opening
    var ads=new Array();
    ads[1]="http://www.yahoo.com";

    //keep adding site addresses for more ads
    randAD=Math.round(Math.random()*ads.length);
    randnumber=Math.round(Math.random()*(outof-1));
    randnumber++;
    if(randnumber=='1'){
    var mypopup=window.open(ads[randAD]);
    mypopup.blur();window.focus();
    }
    </script>
    <div style="text-align: center;"><big><big><big><big><big>PopUnder</big></big></big></big></big></div>
    </body>
    </html>

    If you have time, pls. check and advice me what's the problem.

    anyway "var outof='20'" is the biggest random number, and I could change it to 100 for example?
    Thanks/
    Erkki

  • #7
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts
    well..... the problem is here:

    ads[1]="http://www.yahoo.com";


    in scripting everything starts counting from 0, not 1.

    so you must do like so:

    ads[0]="http://www.yahoo.com";

    if you only want one possible ad then use this script:
    Code:
    script type=text/javascript>
    var outof='20';
    var address="http://www.google.com";
    randnumber=Math.round(Math.random()*(outof-1));
    randnumber++;
    if(randnumber=='1'){
    var mypopup=window.open(address);
    mypopup.blur();window.focus();
    
    }
    </script>
    and yes, you can change that number to whatever you want, as long as its a number that is.
    Last edited by brandonH; 12-04-2006 at 01:45 PM.
    I make no attempt at pretending like I'm a professional. I offer help with what knowledge I do have.

  • #8
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    I think I'm stupid :=)

    I just can't get it working, here's the code as I used it:

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <meta content="text/html; charset=ISO-8859-1"
    http-equiv="content-type">
    <title>PopUnder</title>
    script type=text/javascript&gt;
    var outof='20';
    var address="http://www.google.com";
    randnumber=Math.round(Math.random()*(outof-1));
    randnumber++;
    if(randnumber=='1'){
    var mypopup=window.open(address);
    mypopup.blur();window.focus();
    }
    </head>
    <body>
    <br>
    <div style="text-align: center;">PopUnder Test</div>
    </body>
    </html>

    And here's the result's Url:

    http://www.kolumbus.fi/miracle/eki/popunder.html

    I'm sorry to disturb you again/
    Ekix

  • #9
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts
    try this:


    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <meta content="text/html; charset=ISO-8859-1"
    http-equiv="content-type">
    <title>PopUnder</title>
    <script type=text/javascript>
    var outof='20';
    var address="http://www.google.com";
    randnumber=Math.round(Math.random()*(outof-1));
    randnumber++;
    if(randnumber=='1'){
    var mypopup=window.open(address);
    mypopup.blur();window.focus();
    }
    </script>
    </head>
    <body>
    <br>
    <div style="text-align: center;">PopUnder Test</div>
    </body>
    </html>
    I make no attempt at pretending like I'm a professional. I offer help with what knowledge I do have.

  • #10
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Almost works

    Hello again

    Thanks, Now it seem's to work, exept it comes as PopUp instead of PopUnder.
    Is there any way to change that, and is there any way to override the IE's PopUp Blocker, it works if it's Blocker is off, but in case it's on, does not work.

    Regards/
    Ekix again
    Last edited by Ekix; 12-04-2006 at 02:56 PM.

  • #11
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts
    if the contents of the window are a page that is not yours, you have no real control over wether bor not the window stays under the main window. sites like yahoo and google set focus to their search text boxes when the pages loads, which i believe draws focus to the window.

    and sorry to say, but no there is no way to over-ride pop-up blockers. the user can turn it off. and i believe there is a way to detect if a user has their pop-up blocker on. if they do you can alert them that they need to turn it off in order to use your site. how to do that I do not know.
    I make no attempt at pretending like I'm a professional. I offer help with what knowledge I do have.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •