1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to Block Pop Up Windows inside Frame/iFrame

Discussion in 'Programming' started by rj2kix, Nov 27, 2008.

  1. #1
    Hello,

    I am currently running a few offers inside a frame or an iframe, and while some of the offers are just fine, there are others that have pop up windows.

    This is very disturbing to not only myself, but interrupts the flow of my visitors.

    Is there any way (Javascript or otherwise) to block the pop up windows that the source of a Frame Win or an iFrame Win creates?

    Much appreciation, thanks.
     
    rj2kix, Nov 27, 2008 IP
  2. jaredjb

    jaredjb Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Rj2Kix, I am dealing with this same problem. Did you ever happen to come across a solution? Thanks!

    Jared B.
     
    jaredjb, Mar 28, 2011 IP
  3. steam_cannon

    steam_cannon Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Make a framefilter.php and javascriptfilter.php which your iframe points to.

    HTML

    <IFRAME SRC="http://www.myiframedomain.com/framefilter.php?furl=http://www.domainname.com" WIDTH=1000 HEIGHT=500>
    If you can see this, your browser doesn't
    understand IFRAME. However, we'll still
    <A HREF="http://www.domainname.com">link</A>
    you to the page.
    </IFRAME>

    -------------------------------------------------------------------

    framefilter.php

    <?php

    //Get the raw html.
    $furl=trim($_GET["furl"]);
    $raw = file_get_contents($furl);

    $mydomain="http://www.myiframedomain.com/";

    //Kill anoying popups.
    $raw=str_replace("alert(","isNull(",$raw);
    $raw=str_replace("window.open","isNull",$raw);
    $raw=str_replace("prompt(","isNull(",$raw);
    $raw=str_replace("Confirm: (","isNull(",$raw);

    //Modify the javascript links so they go though a filter.
    $raw=str_replace("script type=\"text/javascript\" src=\"","script type=\"text/javascript\" src=\"".$mydomain."javascriptfilter.php?jurl=",$raw);
    $raw=str_replace("script src=","script src=".$mydomain."javascriptfilter.php?jurl=",$raw);

    //Or kill js files
    //$raw=str_replace(".js",".off",$raw);

    //Put in a base domain tag so images, flash and css are certain to work.
    $replacethis="<head>";
    $replacestring="<head><base href='".$furl."/'>";
    $raw=str_replace($replacethis,$replacestring,$raw);

    //Echo the website html to the iframe.
    echo $raw;

    ?>

    ---------------------------------------------------------------------------

    javascriptfilter.php

    <?php

    //Get the raw html.
    $jurl=trim($_GET["jurl"]);
    $raw = file_get_contents($jurl);

    //Note, if trickyness like decode detected then display empty.
    if(!preg_match("decode(", $raw)){

    //Kill anoying popups.
    $raw=str_replace("alert(","isNull(",$raw);
    $raw=str_replace("window.open","isNull",$raw);
    $raw=str_replace("prompt(","isNull(",$raw);
    $raw=str_replace("Confirm: (","isNull(",$raw);

    //Echo the website html to the iframe.
    echo $raw;

    }

    ?>
     
    steam_cannon, Aug 16, 2011 IP
  4. dccc

    dccc Greenhorn

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #4
    just got the same issue - but with javascript ads code - seems like these guys (I mean "Download" buttons in banner) buying cheap ads traff - then running popunders via own viral to banner network script = profit))) (ad networks do not delete such scam from their rotation as there seems should be profit too) so anyone know how to kill these from site? not iframe but javascript?
     
    dccc, Oct 22, 2016 IP
  5. Einheijar

    Einheijar Well-Known Member

    Messages:
    539
    Likes Received:
    13
    Best Answers:
    3
    Trophy Points:
    165
    #5
    Haven't tested but in theory you should be able to unbind window.unload events.
     
    Einheijar, Oct 22, 2016 IP