使用jquery或php每天弹出一次
如何使用jquery或php每天显示一次FB likebox。我已经使用了弹出窗口,我想将会话或cookie保存在浏览器中。这样我就可以让事情正常进行。目前我正在使用jquery和php使用jquery或php每天弹出一次,php,jquery,Php,Jquery,如何使用jquery或php每天显示一次FB likebox。我已经使用了弹出窗口,我想将会话或cookie保存在浏览器中。这样我就可以让事情正常进行。目前我正在使用jquery和php <body onload="openOffersDialog();"> <script type="text/javascript" src="popup.js"></script> <?php if(!isset($_SESSION['jquery_popu
<body onload="openOffersDialog();">
<script type="text/javascript" src="popup.js"></script>
<?php
if(!isset($_SESSION['jquery_popup']))
{
$_SESSION['jquery_popup'] = "sessionexists";
echo $_SESSION['jquery_popup'];
?>
<script type="text/javascript">
function openOffersDialog() {
$('#overlay').fadeIn('fast', function() {
$('#boxpopup').css('display','block');
$('#boxpopup').animate({'left':'30%'},500);
});
}
function closeOffersDialog(prospectElementID) {
$(function($) {
$(document).ready(function() {
$('#' + prospectElementID).css('position','absolute');
$('#' + prospectElementID).animate({'left':'-100%'}, 500, function() {
$('#' + prospectElementID).css('position','fixed');
$('#' + prospectElementID).css('left','100%');
$('#overlay').fadeOut('fast');
});
});
});
}
</script>
<div id="overlay" class="overlay"></div>
<!--<a onclick="openOffersDialog();">Click Here To See The PopUp</a>-->
<div id="boxpopup" class="box">
<a onclick="closeOffersDialog('boxpopup');" class="boxclose"></a>
<div id="content">
<h2>Like us on Facebook</h2>
<iframe src="http://www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com%2Fkornerseat&width&height=290&colorscheme=light&show_faces=true&header=true&stream=false&show_border=true&appId=474663095902746" scrolling="no" frameborder="0" style="border:none; overflow:hidden; height:290px;" allowTransparency="true"></iframe>
</div>
</div>
<?php
}
?>
函数openOfferDialog(){
$('#overlay').fadeIn('fast',function()){
$('#boxpopup').css('display','block');
$('boxpopup')。动画({'left':'30%},500);
});
}
函数CloseOfferDialog(prospectElementID){
$(函数($){
$(文档).ready(函数(){
$('#'+prospectElementID).css('position','absolute');
$('#'+prospectElementID).animate({'left':'-100%},500,function(){
$('#'+prospectElementID).css('position','fixed');
$('#'+prospectElementID).css('left','100%);
$(“#覆盖”).fadeOut('fast');
});
});
});
}
就像我们在Facebook上一样
按照以前的方式在php代码中添加类似fb的按钮
<?php
if(!isset($_SESSION['jquery_popup']))
{
$_SESSION['jquery_popup'] = "sessionexists";
echo '<iframe src="http://www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com%2Fkornerseat&width&height=290&colorscheme=light&show_faces=true&header=true&stream=false&show_border=true&appId=474663095902746" scrolling="no" frameborder="0" style="border:none; overflow:hidden; height:290px;" allowTransparency="true"></iframe>';
}
?>
注意:假设您之前没有销毁会话变量。如果您想使用cookie,只需将其设置为24小时后死亡,然后检查它是否过期,如果您再次显示弹出窗口 //Javascript版本示例取自
弹出窗口是第二次,我第二次不需要它。24小时一次。有没有办法设置使用jquery@user2959949:然后使用cookie。基于cookie,只需在页面上添加iframe。
function setCookie(cname,cvalue,exdays)
{
var d = new Date();
d.setTime(d.getTime()+(exdays*24*60*60*1000));
var expires = "expires="+d.toGMTString();
document.cookie = cname + "=" + cvalue + "; " + expires;
}
function getCookie(cname)
{
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++)
{
var c = ca[i].trim();
if (c.indexOf(name)==0) return c.substring(name.length,c.length);
}
return "";
}
if(getCookie('jquery_popup') ==""){
setCookie('jquery_popup','sessionexists',1);
//Add code to display popup here
}
if(!isset($_COOKIE['jquery_popup'])){
setcookie("jquery_popup", 'sessionexists', time()+3600*24);
//Add code to display popup here
}