How Do You Do The Following With iFrames

Discussion in 'HTML & JavaScript' started by bobbylove321, Jan 17, 2011.

  1. bobbylove321

    bobbylove321 BANNED BANNED

    Joined:
    Nov 8, 2008
    Messages:
    1,987
    Likes Received:
    2,198
    Hi,

    I want to know how to do the following with iframes and what are the actual codes for them.

    1)How do you iframe a website that has popups, but you don't want the popup or exit splash to appear on your website if you are iframing them?

    2)How do you iframe a percentage of your visitors only for a particular website?

    Example: I would want to iframe only 10% of my visitors for a particular website, so that not all visitors will be counted with the iframe to stay below the radar.

    So far I'm iframing with the following code on my site:

    Code:
    *********Test.js****************************
    var el = document.createElement("iframe");
    el.setAttribute('id', 'ifrm');
    el.setAttribute('style', 'display:none;');
    document.body.appendChild(el);
    el.setAttribute('src', 'http://AnyWebsite.com');
    *********************************************
    And then this goes before the /body tag in the code for my site:

    Code:
    *******************before /body*********************
    <script type="text/javascript" src="Test.js"></script>
    *******************************************************
    So how would I do the following 2 things above that I mentioned continuing with the code provided above?

    Thanks
     
  2. bobbylove321

    bobbylove321 BANNED BANNED

    Joined:
    Nov 8, 2008
    Messages:
    1,987
    Likes Received:
    2,198
    Anyone know how to do this?

    I need to figure it out asap.
     
  3. artizhay

    artizhay BANNED BANNED

    Joined:
    Nov 21, 2010
    Messages:
    1,868
    Likes Received:
    1,336
    I'm not sure about the first part. I'm sure there's some popup killer script someone can give you.

    For the second one, do you have access to a MySQL database? You could just create a table, we'll call it cpa, and have a field called count, which is just an INT. Start it off at 1. Perform a PHP/SQL query to check the value of the field.

    If it's a 1, increment it by 1 and display the frame.
    If it's not a 1 and it's less than 10, increment it by 1 and don't display the frame.
    If it's 10, reset it to 1, but don't display the frame.

    If you don't have access to a MySQL but you are able to read and modify files with PHP, you can store the number in a text file.

    And if you can't do either of those, you could generate a random number between 1 and 10 (with PHP or javascript), and if it's a 1, then display the frame. Not the best method.

    And if you can't do any of that, you could always rotate the offer.
     
    • Thanks Thanks x 1
    Last edited: Jan 17, 2011
  4. bobbylove321

    bobbylove321 BANNED BANNED

    Joined:
    Nov 8, 2008
    Messages:
    1,987
    Likes Received:
    2,198
    artizhay,

    Do you by any chance know how to actually write that kind of code?

    I'm a script writing newbie.

    Thanks
     
  5. locknload007

    locknload007 Power Member

    Joined:
    Apr 14, 2010
    Messages:
    504
    Likes Received:
    74
    Seems like you could do number 2 with simple php. Have it echo 1-10, if it is 10, then run your js, if it is 1-9, echo ''
     
  6. locknload007

    locknload007 Power Member

    Joined:
    Apr 14, 2010
    Messages:
    504
    Likes Received:
    74
    Code:
    <?php
                  
                  $random_number = rand(1,10); 
                  
                  if($random_number > 5){
        $linkis = "http://www.myscript.com/js/";
        }
     
                ?>
                <?php echo $linkis; ?>
                <?php echo $random_number; ?>
    That will spit out a link if the random number is above 5, to see if it is working I added the echo random_number so you can see it spits it out only when it is above 5. Of course it does not do it 50% of the time, but my guess is over time it will be around 50%, you want it to be 10%,so if the number is above 9, it will spit out the link.

    You of course would echo the link where the file needs to be written.

    I have no formal code training, but I can usually get whatever I want to work, and the above works.
     
    • Thanks Thanks x 1
  7. locknload007

    locknload007 Power Member

    Joined:
    Apr 14, 2010
    Messages:
    504
    Likes Received:
    74
    If you want, I got some more code that would change the chance of 10 showing sooner, rather than later. Basically it is a random number between 1-10, if it is not 10, we can do 2-10, if still no 10, then between 3-10, on the 10th try, it will be between 10-10, so it will have to be 10.

    Any time 10 shows up, it goes back to between 1-10. So if you generate a random number between 1-10 and it is 10, then next time it will generate a random number between 1-10, if that one is anything other than 10, it will narrow it down to 2-10, one-in-nine chance now.

    This is a different script that adds on to the one above.
     
    • Thanks Thanks x 1
  8. bobbylove321

    bobbylove321 BANNED BANNED

    Joined:
    Nov 8, 2008
    Messages:
    1,987
    Likes Received:
    2,198
    What would changing the src of the iframe with the javascript do?
     
  9. facebookdude

    facebookdude Jr. VIP Jr. VIP

    Joined:
    Feb 28, 2010
    Messages:
    1,588
    Likes Received:
    2,507
    Wow, this gave me some ideas :) Thanks bobby!
     
    • Thanks Thanks x 1
  10. locknload007

    locknload007 Power Member

    Joined:
    Apr 14, 2010
    Messages:
    504
    Likes Received:
    74
    Then why not just go with

    Code:
    if (rand(1,10) == 5)
       {
       el.setAttribute('style', 'display:inline;');
       }
     
    • Thanks Thanks x 1