相关疑难解决方法(0)

使用cookie仅在第一页加载时加载彩盒

我已尝试从Web上的参考代码在页面加载时仅加载一次特定元素

这是示例代码


    <script type="text/javascript">
        $(document).ready(function(){
    $.colorbox({width:"40%", height:"63%", inline:true, href:"#subscribe"});
}); 
</script>
 <script type="text/javascript"> 
  $(document).ready(function(){
             if (document.cookie.indexOf('visited=true') === -1) {
                   var expires = new Date();
                   expires.setDate(expires.getDate() 31);
                   document.cookie = "visited=true;
expires=" expires.toUTCString();
               } 
             </script> 

有人可以指导我,这个代码有什么问题

这是我正在编辑的html页面


<!DOCTYPE html>
<html lang="en">
    <head>
    <meta charset=utf-8 />
    <title>Popup Subscription Box</title>
    <style type="text/css">
        body{font:12px/1.2 Verdana, Arial, san-serrif; padding:0 10px;}
        a:link, a:visited{text-decoration:none; color:#416CE5; border-bottom:1px solid #416CE5;}
        h2{font-size:13px; margin:15px 0 0 0;}
    </style>
    <link media="screen" rel="stylesheet" href="colorbox.css" />
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script&gt;
    <script src="../colorbox/jquery.colorbox-min.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){ …
Run Code Online (Sandbox Code Playgroud)

javascript jquery colorbox

4
推荐指数
1
解决办法
7877
查看次数

为新用户每15天加载一次Magnific Popup

我有一个简报注册表单,我想每15天加载一次(弹出),否则可能会有点恼人.我目前正在使用此jquery代码在页面加载时加载弹出窗体.

<div id="test-popup" class="white-popup mfp-hide">
Popup Form
</div>

<script>
jQuery(window).load(function(){
jQuery.magnificPopup.open({
items: {src: '#test-popup'},type: 'inline'}, 0);
});
</script>
Run Code Online (Sandbox Code Playgroud)

这在每次访问页面时加载表单时工作正常,但我想限制这一点,以便新用户每15天看一次.不确定15天是最好的做法我想出的东西?

javascript jquery jquery-cookie magnific-popup

3
推荐指数
1
解决办法
2160
查看次数