Html 如何制作一个;“别再问我了。”;选项

Html 如何制作一个;“别再问我了。”;选项,html,css,web,Html,Css,Web,我正在尝试使用css3在我的网站上创建一个对话框,如果用户使用的是adblock,就会弹出这个对话框。对话框基本上要求用户在我的网站上启用广告,但我不想让用户在每次访问我的网站时弹出对话框,因此我想给用户一个“不再显示我”选项,但我不知道如何实现 下面是对话框的图像 <div id="PleaseUnblock" class="modalDialog"> <div style="margin-top: 70px;padding: 5px 12px

我正在尝试使用css3在我的网站上创建一个对话框,如果用户使用的是adblock,就会弹出这个对话框。对话框基本上要求用户在我的网站上启用广告,但我不想让用户在每次访问我的网站时弹出对话框,因此我想给用户一个“不再显示我”选项,但我不知道如何实现

下面是对话框的图像

       <div id="PleaseUnblock" class="modalDialog">
         <div style="margin-top: 70px;padding: 5px 12px 13px 15px;width: 380px;">
            <a href="#" title="Close" class="close">X</a>
            <div style="padding: 0; margin: 0;">
               <h1 class="ad-di-title">You Are Using AdBlock &#58;&#40;</h1>
            </div> 
            <div style="margin-left: auto;margin-right: auto;width: 350px;height: 332px;background: url(/assets/please.jpg);background-size: 350px;background-repeat: no-repeat"></div>
            <p class="ad-di-para" style="margin-bottom: 3px;">All content made on WEBSITENAME is free. As you use Adblock, we wont get any revenue  from the content we make. We promise that we will not show annoying ads and we only ask you to enable ads in our site.</p>
             <a style="margin-left: 300px" href="#" class="kbtn">Ok</a>
         </div> 
       </div>

这是检测adblock用户并打开对话框的java脚本代码

<script> window.setTimeout(function(){
  if(adsbygoogle instanceof Array) {

    // adsbygoogle.js did not execute; probably blocked by an ad blocker
    window.location = '#PleaseUnblock'

  } else {
        // adsbygoogle.js executed 
    }
 }, 2000); 
</script> 
window.setTimeout(函数(){
if(adsbygoogle instanceof数组){
//adsbygoogle.js未执行;可能被广告拦截器阻止
window.location='#请锁定'
}否则{
//adsbygoogle.js已执行
}
}, 2000); 
这是对话框的html代码

       <div id="PleaseUnblock" class="modalDialog">
         <div style="margin-top: 70px;padding: 5px 12px 13px 15px;width: 380px;">
            <a href="#" title="Close" class="close">X</a>
            <div style="padding: 0; margin: 0;">
               <h1 class="ad-di-title">You Are Using AdBlock &#58;&#40;</h1>
            </div> 
            <div style="margin-left: auto;margin-right: auto;width: 350px;height: 332px;background: url(/assets/please.jpg);background-size: 350px;background-repeat: no-repeat"></div>
            <p class="ad-di-para" style="margin-bottom: 3px;">All content made on WEBSITENAME is free. As you use Adblock, we wont get any revenue  from the content we make. We promise that we will not show annoying ads and we only ask you to enable ads in our site.</p>
             <a style="margin-left: 300px" href="#" class="kbtn">Ok</a>
         </div> 
       </div>

您正在使用AdBlock:(
在WEBSITENAME上制作的所有内容都是免费的。当您使用Adblock时,我们不会从我们制作的内容中获得任何收入。我们承诺,我们不会显示令人讨厌的广告,我们只要求您在我们的网站上启用广告


一个使用cookie的相当简单的解决方案:

function askLater() {
    var d = new Date();
    d.setTime(d.getTime() + (86400000)); //set the time to 24 hours later
    var expires = "expires="+d.toUTCString();
    document.cookie = "dontAsk=true; " + expires;
}
如果用户按下“不再问我”按钮,则调用函数
askLater()

然后,在代码中测试cookie任务,例如:

if(adsbygoogle instanceof Array && document.cookie.indexOf("dontAsk") == -1) {
    // indexOf is -1 when string not found, so the cookie is unset

    // adsbygoogle.js did not execute; probably blocked by an ad blocker
    window.location = '#PleaseUnblock'

} else { ... }
如果您不想再问,请使用此选项:

function neverAsk() {
    document.cookie="dontAsk=true";

就这么简单。

使用cookies的一个相当简单的解决方案:

function askLater() {
    var d = new Date();
    d.setTime(d.getTime() + (86400000)); //set the time to 24 hours later
    var expires = "expires="+d.toUTCString();
    document.cookie = "dontAsk=true; " + expires;
}
如果用户按下“不再问我”按钮,则调用函数
askLater()

然后,在代码中测试cookie任务,例如:

if(adsbygoogle instanceof Array && document.cookie.indexOf("dontAsk") == -1) {
    // indexOf is -1 when string not found, so the cookie is unset

    // adsbygoogle.js did not execute; probably blocked by an ad blocker
    window.location = '#PleaseUnblock'

} else { ... }
如果您不想再问,请使用此选项:

function neverAsk() {
    document.cookie="dontAsk=true";

就这么简单。

使用cookies的一个相当简单的解决方案:

function askLater() {
    var d = new Date();
    d.setTime(d.getTime() + (86400000)); //set the time to 24 hours later
    var expires = "expires="+d.toUTCString();
    document.cookie = "dontAsk=true; " + expires;
}
如果用户按下“不再问我”按钮,则调用函数
askLater()

然后,在代码中测试cookie任务,例如:

if(adsbygoogle instanceof Array && document.cookie.indexOf("dontAsk") == -1) {
    // indexOf is -1 when string not found, so the cookie is unset

    // adsbygoogle.js did not execute; probably blocked by an ad blocker
    window.location = '#PleaseUnblock'

} else { ... }
如果您不想再问,请使用此选项:

function neverAsk() {
    document.cookie="dontAsk=true";

就这么简单。

使用cookies的一个相当简单的解决方案:

function askLater() {
    var d = new Date();
    d.setTime(d.getTime() + (86400000)); //set the time to 24 hours later
    var expires = "expires="+d.toUTCString();
    document.cookie = "dontAsk=true; " + expires;
}
如果用户按下“不再问我”按钮,则调用函数
askLater()

然后,在代码中测试cookie任务,例如:

if(adsbygoogle instanceof Array && document.cookie.indexOf("dontAsk") == -1) {
    // indexOf is -1 when string not found, so the cookie is unset

    // adsbygoogle.js did not execute; probably blocked by an ad blocker
    window.location = '#PleaseUnblock'

} else { ... }
如果您不想再问,请使用此选项:

function neverAsk() {
    document.cookie="dontAsk=true";

就这么简单。

从查看cookies开始。从查看cookies开始。从查看cookies开始。从查看cookies开始。