2014-11-06 94 views
-2

嗨,我已經爲我的博客彈出了一小段代碼,並且我不想每次彈出我的讀者時都會激怒我,所以我需要代碼幫助可以使這個彈出窗口每天出現一次。任何幫助將是可觀的。謝謝「每天彈出一次」的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

回答

0

這裏是一個小提琴: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