Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/411.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何用HTML/JS阻止广告?_Javascript_Html_Forum_Phpbb_Ads - Fatal编程技术网

Javascript 如何用HTML/JS阻止广告?

Javascript 如何用HTML/JS阻止广告?,javascript,html,forum,phpbb,ads,Javascript,Html,Forum,Phpbb,Ads,我有一个网站()最近,我开始在页脚上登广告。我查看了页脚,没有关于广告的代码。我想他们把它放在另一个文件中,并将其指定为某个div ID。我可以使用什么HTML或JavaScript代码来隐藏广告,以便其他人看不到它 以下是广告图片: 它是468x60(也许您可以给我一个代码来阻止特定大小的图像显示) 编辑,解决:如果有人在使用“listbb.ru”或“getbb.ru”,下面是解决方案。您需要在索引页上查看源代码,并按CTRL+F键。搜索“混合”或“市场”或类似内容。您将看到类似于“mix_b

我有一个网站()最近,我开始在页脚上登广告。我查看了页脚,没有关于广告的代码。我想他们把它放在另一个文件中,并将其指定为某个div ID。我可以使用什么HTML或JavaScript代码来隐藏广告,以便其他人看不到它

以下是广告图片: 它是468x60(也许您可以给我一个代码来阻止特定大小的图像显示)

编辑,解决:如果有人在使用“listbb.ru”或“getbb.ru”,下面是解决方案。您需要在索引页上查看源代码,并按CTRL+F键。搜索“混合”或“市场”或类似内容。您将看到类似于“mix_block_{identifier}”的内容。要删除它,您需要导航到ACP>Styles>Templates>{Theme}>Overall_header.html> 发现


和之前,输入:

<style>
#mix_block_1294937123 {
display: none;
}
</style>

#混合块1294937123{
显示:无;
}

大多数广告都来自谷歌广告词。因此,javascript在页面中插入了一些内容。如果您只想通过手动检查和删除来删除所有广告


您可以做的另一件事是,通过右键单击并选择选项inspect element in chrome,在浏览器底部打开一个小面板,并将块的CSS属性(右侧)设置为display:none

上面的答案是错误的。要解决广告的自我问题,代码块是:

    <table border="0" cellspacing="0" cellpadding="0">
<tbody><tr>
<td>

<div id="mix_block_1294937123"><div id="mix_block_1294937123_1016" style="width:468px;height:60px;position: relative;"><a href="http://ucl.mixmarket.biz/uni/clk.php?id=1294878201&amp;zid=1294937123&amp;s=9019&amp;tt=08310735" target="blank"><img src="http://is.mixmarket.biz/images/um/95480.gif" width="468" height="60" border="0" alt=""></a></div><script type="text/javascript" src="http://udata.mixmarket.biz/uss/stat/?mid=1294887383&amp;id=1294937123&amp;tt=1472614515"></script><img src="http://mixmarket.biz/t.php?uid=1294929468&amp;r=http%3A//stackoverflow.com/questions/39240278/block-ads-with-html-js&amp;t=1472614515" width="1" height="1"></div>
<script type="text/javascript">
document.write('<scr' + 'ipt language="javascript" type="text/javascript" src="http://1294937123.us.mixmarket.biz/uni/us/1294937123/?div=mix_block_1294937123&r=' + escape(document.referrer) + '&rnd=' + Math.round(Math.random() * 100000) + '" charset="windows-1251"><' + '/scr' + 'ipt>');
</script><script language="javascript" type="text/javascript" src="http://1294937123.us.mixmarket.biz/uni/us/1294937123/?div=mix_block_1294937123&amp;r=http%3A//stackoverflow.com/questions/39240278/block-ads-with-html-js&amp;rnd=39740" charset="windows-1251"></script>
</td></tr></tbody></table>

下面的代码删除网页上方出现的带有不需要的图片和阻止元素的广告

(function removeAdvertisementAndBlockingElements () {
    $('.inRek').remove();
    $('.mgbox').remove();
    
    Array.from(document.getElementsByTagName("img")).forEach(function (e) {
        if (!e.src.includes(window.location.host)) {
            e.remove()
        }
    });    
    
    Array.from(document.getElementsByTagName("div")).forEach(function (e) {
        var currentZIndex = parseInt(document.defaultView.getComputedStyle(e, null).zIndex);
        if (currentZIndex > 999) {
            console.log(parseInt(currentZIndex));
            e.remove()
        }
    });
})();

使用免费网络主机?如果你想删除广告,我建议你为主机付费。我从一个免费的网络主机开始,因为,我已经为一个域和主机付费并进行了迁移,但他们使用了一个overpower将其集成,该功能已经实现到迁移的文件中。Inspect元素不会修复任何问题吗?这是一个非常临时的局部修复。他/她说的是服务器端Andrew是对的,而且这是一位俄罗斯主机,所以广告由另一家公司运营。它只是本地的,我需要为所有用户修复它。
Display: none;
(function removeAdvertisementAndBlockingElements () {
    $('.inRek').remove();
    $('.mgbox').remove();
    
    Array.from(document.getElementsByTagName("img")).forEach(function (e) {
        if (!e.src.includes(window.location.host)) {
            e.remove()
        }
    });    
    
    Array.from(document.getElementsByTagName("div")).forEach(function (e) {
        var currentZIndex = parseInt(document.defaultView.getComputedStyle(e, null).zIndex);
        if (currentZIndex > 999) {
            console.log(parseInt(currentZIndex));
            e.remove()
        }
    });
})();