javascript - 怎么遮挡iframe内嵌第三方页面的广告?
世界只因有你
世界只因有你 2017-05-16 13:07:26
0
4
775

在播放页嵌入第三方解析(一个播放器),手机端播放页-播放器底部有一个高93,自适应宽度的广告~如图,广告很辣眼睛,求帮助,怎么遮挡,或是否可以直接利用JS不让这个广告加载吗

世界只因有你
世界只因有你

reply all(4)
phpcn_u1582

If it is a third-party page, then the iframe embeds a webpage with a different domain name. The browser has security restrictions and is not allowed to access this page. I would like to think about whether there is a way to embed a webpage address that does not contain advertisements

为情所困

You can remove it with $("#iframe的ID").contents().find("#iframe中的广告ID").remove()

phpcn_u1582

Generally speaking, there are cross-domain problems when operating embedded iframes,

没有跨域问题用 js方法 获取iframe里面的对象 来操作是可取的;

有跨域问题,用两个层来做控制,外层包iframe和p:
<p style="position:relative;height:200px;width:400px;border:1px solid red;">
    <iframe src="http://netnr.com" style="position:absolute;width:100%;height:100%"></iframe>
    <p style="position:absolute;bottom:0;left:0;right:0;height:93px;background-color:white;">
        已屏蔽广告
    </p>
</p>
習慣沉默

Upgrade the website to prevent https hijacking. You can apply for a free certificate startsll or let's encrypt

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!