2

ColorBox jQuery Lightboxを使用すると、これはほぼ機能しますが、IEでのみ機能し、FireFoxでは機能しません... Firefoxやその他のMozillaブラウザでこれを機能させるために修正できるアイデアはありますか?

    <!DOCTYPE html>
<html lang="en">
    <head>
    <meta charset=utf-8 />
    <title>Working ColorBox Example Using Cookie</title>
    <style type="text/css">
        body{font:12px/1.2 Verdana, sans-serif; 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 type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/jquery-ui.min.js"></script>
<script src="../colorbox/jquery.colorbox.js"></script>
</head>
<body>
      <script>
$(document).ready(function(){
    if (document.cookie.indexOf('visited=true') === -1) {
        var expires = new Date();
        expires.setDate(expires.getDate()+1); // +1 = in 1 day
        document.cookie = "visited=true; expires="+expires.toUTCString();

        // replace this with your actual call to colorbox.
        $.colorbox({html:"welcome!"});
    }
});
    </script>
Back Page
</body>
</html>
4

1 に答える 1

0

Cookie を作成するためのネイティブ コードは非常に単純なので、単一の Cookie を設定/読み取るためにプラグインを使用するとは思いません。colorbox FAQ にエントリがあります: http://www.jacklmoore.com/colorbox/faq#faq-cookie

あなたにとっては、次のようになります。

$(document).ready(function(){
    if (document.cookie.indexOf('visited=true') === -1) {
        var expires = new Date();
        expires.setDate(expires.getDate()+1); // +1 = in 1 day
        document.cookie = "visited=true; expires="+expires.toUTCString();

        // replace this with your actual call to colorbox.
        $.colorbox({html:"Welcome!"});
    }
});
于 2013-01-14T19:26:47.517 に答える