php allow furl open,如何阻止來自iframe的彈出窗口?

8

If you are wanting to block something like POP up ads or something coming from a website you are showing in an IFRAME - it's fairly easy.

如果你想阻止像POP廣告這樣的東西或來自你在IFRAME中展示的網站的東西 - 這很容易。

Make a framefilter.php and javascriptfilter.php which your iframe points to. You can modify it to meet your needs such as the onload blah blah and etc. But as/is - it's been working fine for me for quite a while. Hope it helps.

制作一個iframe指向的framefilter.php和javascriptfilter.php。您可以修改它以滿足您的需求,例如onload blah blah等等。但是/是 - 它已經為我工作了很長一段時間。希望能幫助到你。

Replace your standard IFRAME HTML with this:

用以下內容替換標准IFRAME HTML:

If you can see this, your browser doesn't

understand IFRAMES. However, we'll still

link

you to the page.

Framefilter.php

//Get the raw html.

$furl=trim($_GET["furl"]);

$raw = file_get_contents($furl);

$mydomain="http://www.yourdomainhere.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="

";

$replacestring="

";

$raw=str_replace($replacethis,$replacestring,$raw);

//Echo the website html to the iframe.

echo $raw;

?>

javascriptfilter.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;

}

?>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值