我希望能够检测用户是否正在使用广告拦截软件,当他们访问我的网站。如果他们正在使用它,我想显示一条消息,要求他们关闭它以支持项目,就像这个网站一样。
如果你进入该网站,而你的浏览器启用了某种广告拦截软件,那么该网站就不会显示真正的广告,而是显示一个小横幅,告诉用户广告收入用于托管项目,他们应该考虑关闭广告拦截。
我想在我的网站上做到这一点,我正在使用adsense广告,我怎么能做到呢?
我希望能够检测用户是否正在使用广告拦截软件,当他们访问我的网站。如果他们正在使用它,我想显示一条消息,要求他们关闭它以支持项目,就像这个网站一样。
如果你进入该网站,而你的浏览器启用了某种广告拦截软件,那么该网站就不会显示真正的广告,而是显示一个小横幅,告诉用户广告收入用于托管项目,他们应该考虑关闭广告拦截。
我想在我的网站上做到这一点,我正在使用adsense广告,我怎么能做到呢?
当前回答
只需在你的网站上添加小脚本:
var isAdsDisplayed = true;
名称为adsbygoogle.js
然后做以下事情:
<script src="/js/adsbygoogle.js"></script>
<script>
if(window.isAdsDisplayed === undefined ) {
// AdBlock is enabled. Show message or track custom data here
}
</script>
找到了这个解
其他回答
在</body>标签关闭之前,在你的页面页脚上运行这个adblock并粘贴这个。
<script type="text/javascript" charset="utf-8"> // Place this code snippet near the footer of your page before the close of the /body tag // eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}(';q O=\'\',29=\'1W\';1S(q i=0;i<12;i++)O+=29.X(B.N(B.K()*29.F));q 2z=1,2u=4p,2v=4o,2x=4n,33=C(e){q i=!1,o=C(){z(k.1g){k.2T(\'2J\',t);D.2T(\'1V\',t)}S{k.2V(\'2L\',t);D.2V(\'27\',t)}},t=C(){z(!i&&(k.1g||4m.2E===\'1V\'||k.2O===\'2K\')){i=!0;o();e()}};z(k.2O===\'2K\'){e()}S z(k.1g){k.1g(\'2J\',t);D.1g(\'1V\',t)}S{k.2M(\'2L\',t);D.2M(\'27\',t);q n=!1;2P{n=D.4k==4j&&k.23}2U(r){};z(n&&n.2Q){(C a(){z(i)G;2P{n.2Q(\'17\')}2U(t){G 4i(a,50)};i=!0;o();e()})()}}};D[\'\'+O+\'\']=(C(){q e={e$:\'1W+/=\',4h:C(t){q a=\'\',d,n,i,c,s,l,o,r=0;t=e.t$(t);1a(r<t.F){d=t.14(r++);n=t.14(r++);i=t.14(r++);c=d>>2;s=(d&3)<<4|n>>4;l=(n&15)<<2|i>>6;o=i&63;z(2Z(n)){l=o=64}S z(2Z(i)){o=64};a=a+U.e$.X(c)+U.e$.X(s)+U.e$.X(l)+U.e$.X(o)};G a},11:C(t){q n=\'\',d,l,c,s,r,o,a,i=0;t=t.1C(/[^A-4g-4f-9\\+\\/\\=]/g,\'\');1a(i<t.F){s=U.e$.1I(t.X(i++));r=U.e$.1I(t.X(i++));o=U.e$.1I(t.X(i++));a=U.e$.1I(t.X(i++));d=s<<2|r>>4;l=(r&15)<<4|o>>2;c=(o&3)<<6|a;n=n+P.T(d);z(o!=64){n=n+P.T(l)};z(a!=64){n=n+P.T(c)}};n=e.n$(n);G n},t$:C(e){e=e.1C(/;/g,\';\');q n=\'\';1S(q i=0;i<e.F;i++){q t=e.14(i);z(t<1s){n+=P.T(t)}S z(t>4e&&t<4d){n+=P.T(t>>6|4c);n+=P.T(t&63|1s)}S{n+=P.T(t>>12|2F);n+=P.T(t>>6&63|1s);n+=P.T(t&63|1s)}};G n},n$:C(e){q i=\'\',t=0,n=4a=1u=0;1a(t<e.F){n=e.14(t);z(n<1s){i+=P.T(n);t++}S z(n>3V&&n<2F){1u=e.14(t+1);i+=P.T((n&31)<<6|1u&63);t+=2}S{1u=e.14(t+1);2f=e.14(t+2);i+=P.T((n&15)<<12|(1u&63)<<6|2f&63);t+=3}};G i}};q a=[\'49==\',\'48\',\'47=\',\'46\',\'45\',\'44=\',\'43=\',\'42=\',\'41\',\'40\',\'3Z=\',\'3Y=\',\'3X\',\'3W\',\'4q=\',\'4b\',\'4r=\',\'4J=\',\'4L=\',\'4M=\',\'4N=\',\'4O=\',\'4P==\',\'4Q==\',\'4K==\',\'4R==\',\'4T=\',\'4U\',\'4V\',\'4W\',\'4X\',\'4Y\',\'4S\',\'4I==\',\'4t=\',\'3T=\',\'4G=\',\'4F==\',\'4E=\',\'4D\',\'4C=\',\'4B=\',\'4A==\',\'4z=\',\'4y==\',\'4x==\',\'4w=\',\'4v=\',\'4u\',\'4s==\',\'3U==\',\'3A\',\'3S==\',\'3k=\'],y=B.N(B.K()*a.F),w=e.11(a[y]),Y=w,Q=1,v=\'#3m\',r=\'#3n\',W=\'#3g\',g=\'#3j\',Z=\'\',b=\'3h!\',p=\'3e 3f 3d 3c\\\'3a 39 38 2n 2m. 3o\\\'s 3l. 3q 3F\\\'t?\',f=\'3R 3Q 3P-3O, 3N 3L\\\'t 3K 3J U 3I 3E.\',s=\'I 3r, I 3D 3C 3B 2n 2m. 3x 3w 3v!\',i=0,u=0,n=\'3u.3t\',l=0,L=t()+\'.2k\';C h(e){z(e)e=e.1R(e.F-15);q i=k.2C(\'3M\');1S(q n=i.F;n--;){q t=P(i[n].1H);z(t)t=t.1R(t.F-15);z(t===e)G!0};G!1};C m(e){z(e)e=e.1R(e.F-15);q t=k.3s;x=0;1a(x<t.F){1n=t[x].1P;z(1n)1n=1n.1R(1n.F-15);z(1n===e)G!0;x++};G!1};C t(e){q n=\'\',i=\'1W\';e=e||30;1S(q t=0;t<e;t++)n+=i.X(B.N(B.K()*i.F));G n};C o(i){q o=[\'3z\',\'3G==\',\'3H\',\'3p\',\'2W\',\'3i==\',\'3b=\',\'37==\',\'4Z=\',\'4H==\',\'52==\',\'5i==\',\'6z\',\'6u\',\'6r\',\'2W\'],r=[\'35=\',\'6B==\',\'6t==\',\'6x==\',\'6d=\',\'6n\',\'62=\',\'6c=\',\'35=\',\'51\',\'6g==\',\'6k\',\'6l==\',\'61==\',\'5X==\',\'6m=\'];x=0;1O=[];1a(x<i){c=o[B.N(B.K()*o.F)];d=r[B.N(B.K()*r.F)];c=e.11(c);d=e.11(d);q a=B.N(B.K()*2)+1;z(a==1){n=\'//\'+c+\'/\'+d}S{n=\'//\'+c+\'/\'+t(B.N(B.K()*20)+4)+\'.2k\'};1O[x]=26 1T();1O[x].1X=C(){q e=1;1a(e<7){e++}};1O[x].1H=n;x++}};C M(e){};G{2X:C(e,r){z(6j k.J==\'6i\'){G};q i=\'0.1\',r=Y,t=k.1d(\'1y\');t.1k=r;t.j.1h=\'1D\';t.j.17=\'-1o\';t.j.V=\'-1o\';t.j.1t=\'2b\';t.j.13=\'6h\';q d=k.J.2p,a=B.N(d.F/2);z(a>15){q n=k.1d(\'2d\');n.j.1h=\'1D\';n.j.1t=\'1r\';n.j.13=\'1r\';n.j.V=\'-1o\';n.j.17=\'-1o\';k.J.5Y(n,k.J.2p[a]);n.1f(t);q o=k.1d(\'1y\');o.1k=\'2h\';o.j.1h=\'1D\';o.j.17=\'-1o\';o.j.V=\'-1o\';k.J.1f(o)}S{t.1k=\'2h\';k.J.1f(t)};l=6b(C(){z(t){e((t.1Y==0),i);e((t.21==0),i);e((t.1K==\'2H\'),i);e((t.1Q==\'2g\'),i);e((t.1J==0),i)}S{e(!0,i)}},28)},1G:C(t,c){z((t)&&(i==0)){i=1;D[\'\'+O+\'\'].1z();D[\'\'+O+\'\'].1G=C(){G}}S{q f=e.11(\'6a\'),u=k.69(f);z((u)&&(i==0)){z((2u%3)==0){q l=\'68=\';l=e.11(l);z(h(l)){z(u.1F.1C(/\\s/g,\'\').F==0){i=1;D[\'\'+O+\'\'].1z()}}}};q y=!1;z(i==0){z((2v%3)==0){z(!D[\'\'+O+\'\'].2y){q d=[\'67==\',\'66==\',\'6o=\',\'5Z=\',\'6p=\'],m=d.F,r=d[B.N(B.K()*m)],a=r;1a(r==a){a=d[B.N(B.K()*m)]};r=e.11(r);a=e.11(a);o(B.N(B.K()*2)+1);q n=26 1T(),s=26 1T();n.1X=C(){o(B.N(B.K()*2)+1);s.1H=a;o(B.N(B.K()*2)+1)};s.1X=C(){i=1;o(B.N(B.K()*3)+1);D[\'\'+O+\'\'].1z()};n.1H=r;z((2x%3)==0){n.27=C(){z((n.13<8)&&(n.13>0)){D[\'\'+O+\'\'].1z()}}};o(B.N(B.K()*3)+1);D[\'\'+O+\'\'].2y=!0};D[\'\'+O+\'\'].1G=C(){G}}}}},1z:C(){z(u==1){q E=2A.6s(\'2B\');z(E>0){G!0}S{2A.6y(\'2B\',(B.K()+1)*28)}};q h=\'6f==\';h=e.11(h);z(!m(h)){q c=k.1d(\'5u\');c.1Z(\'5V\',\'5r\');c.1Z(\'2E\',\'1m/5q\');c.1Z(\'1P\',h);k.2C(\'5o\')[0].1f(c)};5n(l);k.J.1F=\'\';k.J.j.16+=\'R:1r !19\';k.J.j.16+=\'1B:1r !19\';q L=k.23.21||D.36||k.J.21,y=D.5m||k.J.1Y||k.23.1Y,a=k.1d(\'1y\'),Q=t();a.1k=Q;a.j.1h=\'2r\';a.j.17=\'0\';a.j.V=\'0\';a.j.13=L+\'1x\';a.j.1t=y+\'1x\';a.j.2G=v;a.j.24=\'5l\';k.J.1f(a);q d=\'<a 1P="5k://5j.5W" j="H-1e:10.5h;H-1j:1i-1l;1c:5f;">1U 53 5e</a>\';d=d.1C(\'5d\',t());d=d.1C(\'5c\',t());q o=k.1d(\'1y\');o.1F=d;o.j.1h=\'1D\';o.j.1A=\'1L\';o.j.17=\'1L\';o.j.13=\'5b\';o.j.1t=\'5a\';o.j.24=\'2l\';o.j.1J=\'.6\';o.j.2e=\'2j\';o.1g(\'59\',C(){n=n.58(\'\').57().56(\'\');D.2D.1P=\'//\'+n});k.1E(Q).1f(o);q i=k.1d(\'1y\'),M=t();i.1k=M;i.j.1h=\'2r\';i.j.V=y/7+\'1x\';i.j.5s=L-5g+\'1x\';i.j.5t=y/3.5+\'1x\';i.j.2G=\'#5I\';i.j.24=\'2l\';i.j.16+=\'H-1j: "5U 5T", 1v, 1w, 1i-1l !19\';i.j.16+=\'5S-1t: 5R !19\';i.j.16+=\'H-1e: 5Q !19\';i.j.16+=\'1m-1p: 1q !19\';i.j.16+=\'1B: 5P !19\';i.j.1K+=\'1U\';i.j.2I=\'1L\';i.j.5O=\'1L\';i.j.5N=\'2q\';k.J.1f(i);i.j.5L=\'1r 5K 5J -5H 5v(0,0,0,0.3)\';i.j.1Q=\'32\';q Y=30,w=22,x=18,Z=18;z((D.36<34)||(5G.13<34)){i.j.2S=\'50%\';i.j.16+=\'H-1e: 5E !19\';i.j.2I=\'5C;\';o.j.2S=\'65%\';q Y=22,w=18,x=12,Z=12};i.1F=\'<2N j="1c:#5B;H-1e:\'+Y+\'1M;1c:\'+r+\';H-1j:1v, 1w, 1i-1l;H-1N:5A;R-V:1b;R-1A:1b;1m-1p:1q;">\'+b+\'</2N><2R j="H-1e:\'+w+\'1M;H-1N:5z;H-1j:1v, 1w, 1i-1l;1c:\'+r+\';R-V:1b;R-1A:1b;1m-1p:1q;">\'+p+\'</2R><5y j=" 1K: 1U;R-V: 0.2Y;R-1A: 0.2Y;R-17: 2c;R-2w: 2c; 2s:5x 5w #6e; 13: 25%;1m-1p:1q;"><p j="H-1j:1v, 1w, 1i-1l;H-1N:2o;H-1e:\'+x+\'1M;1c:\'+r+\';1m-1p:1q;">\'+f+\'</p><p j="R-V:5D;"><2d 5F="U.j.1J=.9;" 5M="U.j.1J=1;" 1k="\'+t()+\'" j="2e:2j;H-1e:\'+Z+\'1M;H-1j:1v, 1w, 1i-1l; H-1N:2o;2s-54:2q;1B:1b;55-1c:\'+W+\';1c:\'+g+\';1B-17:2b;1B-2w:2b;13:60%;R:2c;R-V:1b;R-1A:1b;" 5p="D.2D.6A();">\'+s+\'</2d></p>\'}}})();D.2t=C(e,t){q n=6v.6w,i=D.6q,a=n(),o,r=C(){n()-a<t?o||i(r):e()};i(r);G{3y:C(){o=1}}};q 2i;z(k.J){k.J.j.1Q=\'32\'};33(C(){z(k.1E(\'2a\')){k.1E(\'2a\').j.1Q=\'2H\';k.1E(\'2a\').j.1K=\'2g\'};2i=D.2t(C(){D[\'\'+O+\'\'].2X(D[\'\'+O+\'\'].1G,D[\'\'+O+\'\'].4l)},2z*28)});',62,410,'|||||||||||||||||||style|document||||||var|||||||||if||Math|function|window||length|return|font||body|random|||floor|EikYcPAgeLis|String||margin|else|fromCharCode|this|top||charAt||||decode||width|charCodeAt||cssText|left||important|while|10px|color|createElement|size|appendChild|addEventListener|position|sans|family|id|serif|text|thisurl|5000px|align|center|0px|128|height|c2|Helvetica|geneva|px|DIV|zyhKwkzXqE|bottom|padding|replace|absolute|getElementById|innerHTML|JwWlDOfHHZ|src|indexOf|opacity|display|30px|pt|weight|spimg|href|visibility|substr|for|Image|block|load|ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789|onerror|clientHeight|setAttribute||clientWidth||documentElement|zIndex||new|onload|1000|mXZWAWPhDt|babasbmsgx|60px|auto|div|cursor|c3|none|banner_ad|ZExTcInByX|pointer|jpg|10000|blocker|ad|300|childNodes|15px|fixed|border|LWzjLrdKIW|wukVDWmHGV|DGAbzCJMei|right|KoGbDZZBdI|ranAlready|GhxORUYrSp|sessionStorage|babn|getElementsByTagName|location|type|224|backgroundColor|hidden|marginLeft|DOMContentLoaded|complete|onreadystatechange|attachEvent|h3|readyState|try|doScroll|h1|zoom|removeEventListener|catch|detachEvent|cGFydG5lcmFkcy55c20ueWFob28uY29t|kxrotXXdJo|5em|isNaN|||visible|YueVFIKLqs|640|ZmF2aWNvbi5pY28|innerWidth|YWR2ZXJ0aXNpbmcuYW9sLmNvbQ|an|using|re|YWdvZGEubmV0L2Jhbm5lcnM|you|like|It|looks|adb8ff|Welcome|YS5saXZlc3BvcnRtZWRpYS5ldQ|FFFFFF|c3BvbnNvcmVkX2xpbms|okay|EEEEEE|777777|That|YWQuZm94bmV0d29ya3MuY29t|Who|understand|styleSheets|kcolbdakcolb|moc|in|me|Let|clear|YWRuLmViYXkuY29t|Z29vZ2xlX2Fk|my|disabled|have|awesome|doesn|YWQubWFpbC5ydQ|anVpY3lhZHMuY29t|site|making|keep|can|script|we|income|advertising|without|But|b3V0YnJhaW4tcGFpZA|QWRCb3gxNjA|YWRzZW5zZQ|191|QWQzMDB4MjUw|QWQzMDB4MTQ1|YWQtY29udGFpbmVyLTI|YWQtY29udGFpbmVyLTE|YWQtY29udGFpbmVy|YWQtZm9vdGVy|YWQtbGI|YWQtbGFiZWw|YWQtaW5uZXI|YWQtaW1n|YWQtaGVhZGVy|YWQtZnJhbWU|YWRCYW5uZXJXcmFw|YWQtbGVmdA|c1|QWRBcmVh|192|2048|127|z0|Za|encode|setTimeout|null|frameElement|VBTxktzQKI|event|190|277|295|QWQ3Mjh4OTA|QWRGcmFtZTE|cG9wdXBhZA|QWREaXY|YWRzbG90|YmFubmVyaWQ|YWRzZXJ2ZXI|YWRfY2hhbm5lbA|IGFkX2JveA|YmFubmVyYWQ|YWRBZA|YWRiYW5uZXI|YWRCYW5uZXI|YmFubmVyX2Fk|YWRUZWFzZXI|Z2xpbmtzd3JhcHBlcg|QWRDb250YWluZXI|cHJvbW90ZS5wYWlyLmNvbQ|QWRJbWFnZQ|QWRGcmFtZTI|QWRzX2dvb2dsZV8wMw|QWRGcmFtZTM|QWRGcmFtZTQ|QWRMYXllcjE|QWRMYXllcjI|QWRzX2dvb2dsZV8wMQ|QWRzX2dvb2dsZV8wMg|QWRzX2dvb2dsZV8wNA|RGl2QWRD|RGl2QWQ|RGl2QWQx|RGl2QWQy|RGl2QWQz|RGl2QWRB|RGl2QWRC|Y2FzLmNsaWNrYWJpbGl0eS5jb20||YWQtbGFyZ2UucG5n|YWRzLnlhaG9vLmNvbQ|adblock|radius|background|join|reverse|split|click|40px|160px|FILLVECTID2|FILLVECTID1|plugin|black|120|5pt|YWRzLnp5bmdhLmNvbQ|blockadblock|http|9999|innerHeight|clearInterval|head|onclick|css|stylesheet|minWidth|minHeight|link|rgba|solid|1px|hr|500|200|999|45px|35px|18pt|onmouseover|screen|8px|fff|24px|14px|boxShadow|onmouseout|borderRadius|marginRight|12px|16pt|normal|line|Black|Arial|rel|com|d2lkZV9za3lzY3JhcGVyLmpwZw|insertBefore|Ly9hZHMudHdpdHRlci5jb20vZmF2aWNvbi5pY28||bGFyZ2VfYmFubmVyLmdpZg|YWRjbGllbnQtMDAyMTQ3LWhvc3QxLWJhbm5lci1hZC5qcGc||||Ly93d3cuZ3N0YXRpYy5jb20vYWR4L2RvdWJsZWNsaWNrLmljbw|Ly93d3cuZ29vZ2xlLmNvbS9hZHNlbnNlL3N0YXJ0L2ltYWdlcy9mYXZpY29uLmljbw|Ly9wYWdlYWQyLmdvb2dsZXN5bmRpY2F0aW9uLmNvbS9wYWdlYWQvanMvYWRzYnlnb29nbGUuanM|querySelector|aW5zLmFkc2J5Z29vZ2xl|setInterval|Q0ROLTMzNC0xMDktMTM3eC1hZC1iYW5uZXI|c2t5c2NyYXBlci5qcGc|CCC|Ly95dWkueWFob29hcGlzLmNvbS8zLjE4LjEvYnVpbGQvY3NzcmVzZXQvY3NzcmVzZXQtbWluLmNzcw|c3F1YXJlLWFkLnBuZw|468px|undefined|typeof|ZmF2aWNvbjEuaWNv|YmFubmVyX2FkLmdpZg|YWR2ZXJ0aXNlbWVudC0zNDMyMy5qcGc|MTM2N19hZC1jbGllbnRJRDI0NjQuanBn|Ly9hZHZlcnRpc2luZy55YWhvby5jb20vZmF2aWNvbi5pY28|Ly93d3cuZG91YmxlY2xpY2tieWdvb2dsZS5jb20vZmF2aWNvbi5pY28|requestAnimationFrame|YXMuaW5ib3guY29t|getItem|NDY4eDYwLmpwZw|YWRzYXR0LmVzcG4uc3RhcndhdmUuY29t|Date|now|NzIweDkwLmpwZw|setItem|YWRzYXR0LmFiY25ld3Muc3RhcndhdmUuY29t|reload|YmFubmVyLmpwZw'.split('|'),0,{})); </script> And for Javascript Blocking Protection add the following style element to your <body> tag at the top of your page:
visibility:hidden
style="visibility: hidden !important;"
<body style="可见性:隐藏!重要;">
然后在<body>标签后面立即添加下面的DIV标签
<div id="babasbmsgx" style="visibility: visible !important;">Please disable your adblock and script blockers to view this page</div>
AdBlock似乎阻止加载AdSense(等)JavaScript文件。所以,如果你使用异步版本的AdSense广告,你可以检查adsbygoogle是否是一个数组。这必须在几秒钟后检查,因为异步脚本是…异步的。以下是一个大致的大纲:
window.setTimeout(function(){
if(adsbygoogle instanceof Array) {
// adsbygoogle.js did not execute; probably blocked by an ad blocker
} else {
// adsbygoogle.js executed
}
}, 2000);
为了澄清,这里有一个AdSense异步广告代码的示例:
<!-- this can go anywhere -->
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- this is where the ads display -->
<ins class="adsbygoogle" ...></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
注意adsbygoogle被初始化为一个数组。adsbygoogle.js库将此数组更改为Object {push:…}当它执行时。在一段时间后检查变量的类型可以告诉您脚本是否已加载。
如果你正在使用react和钩子:
import React, { useState, useEffect } from 'react'
const AdblockDetect = () => {
const [usingAdblock, setUsingAdblock] = useState(false)
let fakeAdBanner
useEffect(() => {
if (fakeAdBanner) {
setUsingAdblock(fakeAdBanner.offsetHeight === 0)
}
})
if (usingAdblock === true) {
return null
}
return (
<div>
<div
ref={r => (fakeAdBanner = r)}
style={{ height: '1px', width: '1px', visibility: 'hidden', pointerEvents: 'none' }}
className="adBanner"
/>
Adblock!
</div>
)
}
export default AdblockDetect
我的建议是:不要这样做!
在任何情况下,你把人们视为“做错事的人”都会导致他们反击。
这是我的建议。
在页面顶部放一个不显眼的小消息(不管广告是否被阻止),文字我完全尊重你阻止广告的权利,并链接到另一个页面/弹出标题为阅读更多....
在另一页上,清楚地表明你明白这是他们的电脑,他们可以自由地使用广告拦截。
也要以一种非指责的方式明确表示,使用这些拦截器会让你更难发布优质内容(详细解释原因),虽然你不希望广告拦截器出现在你的网站上,但这完全是他们的决定。专注于关闭阻塞的积极方面。
那些强烈反对广告的人会忽略这一点,但你从来没有机会说服他们。那些漠不关心的人很可能会被你的吸引力所动摇,因为你没有做“让我走我的路,否则我就拿着我的球回家”的事情,老实说,这应该是五岁孩子的专属领域。
记住,没有人拿枪指着你的头强迫你把东西放到网上。尊重你的读者/用户,你可能会发现很多人会回报你。
如果你使用jQuery和谷歌Adsense:
jQuery.getScript(
"https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js",
function() {
// Load your ad now
}).fail(function() {
// Google failed to load main script, do something now
});
这更容易理解:如果谷歌广告主JavaScript文件加载失败,AdSense将无法工作,所以您使用jQuery的fail函数做一些事情。
“loading your add now”是当我添加“ins”对象时,比如:
jQuery(".my_ad_div").append('<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-xxx"
data-ad-slot="xxx"
data-ad-format="auto"
data-full-width-responsive="true"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>');
在“//谷歌加载主脚本失败,现在做点什么”中,我通常把图像放在广告的地方。