“每天弹出一次”的Javascript代码

问题描述:

嗨,我已经为我的博客弹出了一小段代码,并且我不想每次弹出我的读者时都会激怒我,所以我需要代码帮助可以使这个弹出窗口每天出现一次。任何帮助将是可观的。谢谢“每天弹出一次”的Javascript代码

<style type='text/css'> 
#alltechcorner div.overlay { 
background-color: #000; 
} 

#alltechcorner { 
position:fixed !important; 
position:absolute; 
top:80px; 
left:34%; 
margin:0px 0px 0px -152px; 
width:650px; 
height:auto; 
padding:16px; 
background:#000; 
font-family:Nunito; 
color:#fff; 
border:2px solid #333; 
-webkit-box-shadow:0px 1px 2px rgba(0,0,0,0.4); 
-moz-box-shadow:0px 1px 2px rgba(0,0,0,0.4); 
box-shadow: 2px 4px 9px #000; 
-webkit-border-radius:10px; 
-moz-border-radius:10px; 
border-radius:10px; 
z-index: 999999; 
} 

    .subl{float:left; height:400px; width:300px; position: absolute; top:150px;} 
    .subr{float:right; height:400px; width:300px;} 
    .gplus{} 
    .imgsub{} 
    .img{} 
    .fbox{background: white; border-radius:5px;border:none; overflow:hidden; width:300px; height:185px;} 

#alltechcorner a.alltechcornerclose { 
position:absolute; 
top:-10px; 
right:-10px; 
background:#fff; 
font:bold 16px Arial, Sans-Serif; 
text-decoration:none; 
line-height:22px; 
width:22px; 
text-align:center; 
color:#000000; 
border:2px solid #333; 
-webkit-box-shadow:0px 1px 2px rgba(0,0,0,0.4); 
-moz-box-shadow:0px 1px 2px rgba(0,0,0,0.4); 
box-shadow:0px 1px 2px rgba(0,0,0,0.4); 
-webkit-border-radius:22px; 
-moz-border-radius:22px; 
border-radius:25px; 
cursor:pointer; 
z-index: 9999; 
} 

@media all and (max-width: 1000px) { 

    #alltechcorner { 
    width: 260px; 
position:relative; 
height: auto; 
top:30px; 
left:51%; 
right:50%; 
padding:16px; 
    } 
    #alltechcorner img{width:260px} 
    #alltechcorner .img{width:150px} 
    #alltechcorner .subl{width:260px;position: relative; top:0px;} 
    #alltechcorner .gplus{display:none} 
    #alltechcorner .fbox{width:240px; height:100px} 
    #alltechcorner .subr{float:left; width:240px; padding:10px; position: absolute; top: 305px;} 
#alltechcorner .imgsub{width:200px} 
} 


</style> 
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js' type='text/javascript'/> 
<script type='text/javascript'> 
$(window).bind(&quot;load&quot;, function() { 
// Widget by www.alltechcorner.com 
$(&#39;a.alltechcornerclose&#39;).click(function() { 
$(this).parent().fadeOut(); 
return false; 
}); 
}); 
</script> 

<div id='alltechcorner'> 
<div class='overlay' style='opacity: 0.8; height: 1000px; width: 1263px; position: fixed; left: 0px; top: 0px; z-index: -999999;'/> 

<center> 
<img src='http://4.bp.blogspot.com/-mq2v3aTDXh0/VFrs4P_qDYI/AAAAAAAAFRA/tPD-kFdxCjA/s1600/header.png' width="645px"/><br/> 
<div class='subl' style=''> 
    <img src='http://2.bp.blogspot.com/-XB4x7DpQhzY/VFroGc_YB4I/AAAAAAAAFQg/jDatmEU4KZ8/s1600/Subscribe.png'/><br/> 
<form action='http://feedburner.google.com/fb/a/mailverify' method='post' onsubmit='window.open(&apos;http://feedburner.google.com/fb/a/mailverify?uri=ShowMeJob&apos;, &apos;popupwindow&apos;, &apos;scrollbars=yes,width=550,height=520&apos;);return true' style='background: #000; border:1px solid #ccc;padding:3px;text-align:center; border-radius:5px; ' target='popupwindow'><br/><p>We hate spam as much as you do.<br/>We promise we won&#39;t spam you!<br/> You can unsubscribe anytime.</p><br/><p><input name='email' placeholder='Enter your email address' style='height:20px;width:200px;border-radius:5px;text-align:center;' type='text'/></p><input name='uri' type='hidden' value='ShowMeJob'/><br/><input name='loc' type='hidden' value='en_US'/><input id='imgsub' name='submit' src='http://1.bp.blogspot.com/-wJ6Lml4QwkU/VFrgetl3dvI/AAAAAAAAFP0/dV61wTz62LY/s1600/Submit.png' type='image' value='Subscribe' width='220px'/><br/><br/></form><br/><br/></div> 

<div class='subr'> 
<img class='img' src='http://2.bp.blogspot.com/-0zuoF4WqSSk/VFrk7b9BjEI/AAAAAAAAFQI/n4ozPZnAwwM/s1600/facebook.png'/> 
<iframe allowtransparency='true' class='fbox' frameborder='0' scrolling='no' src='//www.facebook.com/plugins/likebox.php?href=https%3A%2F%2Fwww.facebook.com%2Falltechcorner&amp;width=300&amp;height=200&amp;show_faces=true&amp;colorscheme=light&amp;stream=false&amp;show_border=true&amp;header=false&amp;appId=196282097100252' style=''/><div class='gplus'><br/><img src='http://4.bp.blogspot.com/-x0GP1JeilD0/VFrmgi87bGI/AAAAAAAAFQU/DxBL11IrxDE/s1600/G%2B.png'/><br/> 

<script src='https://apis.google.com/js/platform.js'/> 
<div class='g-page' data-href='//plus.google.com/u/0/102766145090467572848' data-layout='landscape' data-rel='publisher' data-style='border-radius:5px;' data-width='295'/><br/> 

<span style='font-size:10px;'><a href='http://www.alltechcorner.com/2014/05/fb-like-box-and-subscription-box-in-single-pop-up.html' style='color: aqua;' target='_blank'>Get this Widget</a><br/></span></div></div> 
</center> 

<a class='alltechcornerclose' href='#'>&#215;</a> 

</div> 
+0

我不是downvoter,但在http://stackoverflow.com/questions/4455282/call-a-javascript-function-at-a-specific-time-of-day之前询问过类似的问题,请尝试这并看看是否有任何帮助。 – chaitanya89 2014-11-06 11:06:33

+1

如果他们留下了一些新人的见解,下楼者也会更有帮助......而@chaitanya89,你的链接并不能解决人们来到这里的问题,我认为这里应该使用cookie方法。 – adrenalin 2014-11-06 11:09:50

这里是一个小提琴:http://jsfiddle.net/or9s4g7e/1/

我基本上是加了cookie library和改变使用jQuery准备,而不是onload事件。

$(function() { 
    // If cookie exists, hide popup 
    var cookie = $.cookie('hasBeenHere'); 
    if (cookie) { 
    $('#alltechcorner').css('display', 'none'); 
    } 

    // Widget by www.alltechcorner.com 
    $("a.alltechcornerclose").click(function() { 
    $(this).parent().fadeOut(); 
    $.cookie('hasBeenHere', '1', 1); 
    return false; 
    }); 
}); 

而且我建议透露出弹出(其上具有display: none为默认,如果cookie不存在,与display: block显示它当时的),因为这将删除谁是重装您网页的人忽隐忽现。

+0

感谢您的帮助** @肾上腺素**。对不起,我迟到了回应你,但要说代码不工作:(你可以帮助其他人吗? – Muji 2014-11-17 16:53:35

+0

它是如何工作的?我可以模拟代码没有问题,但由于懒惰,我没有开始找到'a.alltechcornerclose'的位置,我只是从控制台触发该点击事件并且可以验证它是否工作。 – adrenalin 2014-11-18 03:10:01