javascript - 想要去除iframe广告,可他的ID值每刷新一次,后面的5个英文都在变?
我想大声告诉你
我想大声告诉你 2017-05-16 13:11:14
0
3
588

$("#iframe的ID").contents().find("#iframe中的广告ID").remove()
本来利用这个代码去除引用iframe的广告,可每个页面的广告id一刷新就更新Cpg23241154qzkmv Cpg23241154ustep Cpg23241154gvhzk 怎么写能赋予这个ID是动态的。

我想大声告诉你
我想大声告诉你

reply all (3)
迷茫

It seems that its ID is quite regular, basically starting with "Cpg", then the processing is as follows

$("#iframe的ID").contents().find('[id^="Cpg"]').remove();
    巴扎黑

    This kind of direct query for iframes excludes those in your own site and blocks all others, or you can determine whether the name of the iframe meets a certain rule and then block it

      黄舟

      If you can find a pattern, write a regular rule

      It starts with Cpg, the middle 8 characters are always numbers, and the last 5 characters are lowercase letters:

      ^Cpg\d{8}[a-z]{5}$

      Start with Cpg23241154, the last 5 are numbers or letters:

      ^Cpg23241154\w{5}$
        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!