search

Home  >  Q&A  >  body text

javascript - How to block ads from third-party pages embedded in iframes?

Embed a third-party parser (a player) on the playback page. On the mobile playback page - there is an advertisement with a height of 93 and an adaptive width at the bottom of the player ~ as shown, the advertisement is very eye-catching, please help, how to block it, or Is it possible to directly use JS to prevent this ad from loading?

世界只因有你世界只因有你2829 days ago878

reply all(4)I'll reply

  • phpcn_u1582

    phpcn_u15822017-05-16 13:09:26

    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

    reply
    0
  • 为情所困

    为情所困2017-05-16 13:09:26

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

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-05-16 13:09:26

    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>

    reply
    0
  • 習慣沉默

    習慣沉默2017-05-16 13:09:26

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

    reply
    0
  • Cancelreply