English 中文(简体)
显示彩色框加载页面装入
原标题:Display Colorbox Onload Page Load

我正在研究代码,它将首次用ColorBox传递给访客信息。我一直在偷看代码,这是我目前为止拥有的...

<html>
<head>
<script type="text/javascript">
<script src="../colorbox/jquery.colorbox.js"></script>
<script type="text/javascript" src="scripts/jquery.cookies.2.2.0.min.js"></script>

<script>


function loadMsg()
{
$(document).ready(function(){
if ($.cookie( newsletter ) !=  0 ) {
$.colorbox({href:"newsletter.html"});
$.cookie( newsletter ,  1 , { expires: 60}); }
}}

</script>
</head>

<body onload="loadMsg()">
<h1>Hello World!</h1>
</body>
</html>

你能帮我弄清楚我错过了什么吗?

问题回答

您在 cookie 中使用什么插件? 我怀疑$. cookie( 通讯) 在没有 cookie 存在时会返回字符串值 0 。 我想它会返回错误值 。 您确定它不应该是这样的 :

if (!$.cookie( newsletter )) {
    $.colorbox({href:"newsletter.html"});
    $.cookie( newsletter ,  1 , { expires: 60}); }
}

或者放下 cookie 插件, 并写入您自己的 cookie 检测代码 。 这样一例一次性使用并不困难 。

上面的代码可能是 spitting 不是一个函数 , 是未定义的 错误 。

s 今天应该使用的 < strong > 更新代码 (通知我使用 < a href=" "http://plugins.jquery.com/cookie/" rel="nofollow" >jQuery Cookie Cookie 图书馆 ):

<html>
<head>

<script type="text/javascript" src="/js/colorbox/jquery.colorbox-min.js"></script>
<script type="text/javascript" src="/js/jquery-cookie/jquery.cookie.js"></script>

<script type="text/javascript">

    function loadMsg(){

        jQuery.noConflict();
        jQuery(document).ready(function(){
            if (!jQuery.cookie( popupcookie )) {
                jQuery.colorbox({href:"newsletter.html", width: 640, height: 460});
                jQuery.cookie( popupcookie ,  1 , { expires: 1}); }
        })}

</script>
</head>

<body onload="loadMsg()">
  <h1>Hello World!</h1>
</body>

</html>

这应该能让你走。在这个例子中,过期时间被设定为1天btw。





相关问题
How to suppress/remove PHP session cookie

I need to suppress an already set session cookie header, but I cannot find any way to do this. Why? I need to make an image, sent by a PHP script, cacheable by the end user; this image is used to ...

Remove Cookies from JS or CSS files

Bizarrely my javascript and css files have cookies (says Firebug). I use Zend Framework and I think it has to do with it. Could I change the .htaccess that CSS or JS files don t link to the ZF or is ...

httplib2, how to set more than one cookie?

As you are probably aware, more often than not, an HTTP server will send more than just a session_id cookie; however, httplib2 handles cookies with a dictionary, like this: response, content = http....

cookies control

what tool wold you recommend me to use in order to see what data are stored in my cookies while i m browsing the net. I m a beginner into webdev field(6 months php experience) and i m curious to see ...

热门标签