简体   繁体   English

'jekyll'会干扰jquery.cookie吗?

[英]Could 'jekyll' interfere with jquery.cookie?

I have managed to implement jquery.cookie in another project with fancyapp with no problems; 我已经成功地在另一个使用fancyapp的项目中实现了jquery.cookie; eg tested modal fires once, and to make it fire again I just delete the cookie and it will propagate again (see below). 例如,经过测试的模式触发一次,然后再次触发,我只是删除cookie,它将再次传播(见下文)。

UPDATE 更新

Here is the example where it works; 这是它起作用的示例; If you go to this page: http://avonexampleone.antonio-p-ortiz.com/prior.html click the banner, the modal will fire in the subsequent page and honor the expiration iejcookie('visited', 'yes', {expires: 1}); 如果您转到此页面: http : iejcookie('visited', 'yes', {expires: 1});单击横幅,该模式将在随后的页面中触发并遵守有效期iejcookie('visited', 'yes', {expires: 1}); wont fire again till a day, And if you clear your cookies and test again the modal will fire. 直到一天后都不会触发,如果您清除Cookie并再次测试,该模式就会触发。 All as expected. 一切都如预期。

However, I have the same code in another project (jekyll blog), and it appears to work once in a while when tested. 但是,我在另一个项目(jekyll博客)中有相同的代码,并且经过测试似乎偶尔可以工作。

Could there be some weird privacy concern or some setting in jekyll which would prevent this? 可能会有一些奇怪的隐私问题或jekyll中的某些设置可以防止这种情况发生吗?

Any help would be appreciated! 任何帮助,将不胜感激!

HTML: HTML:

<a id="clickbanner" href="/assets/images/beauty_for_a_purpose/Beauty_for_a_Purpose_Sheri_Card_EN.jpg" rel="gallery"></

JS: JS:

var j = jQuery.noConflict();

j(document).ready(function() {
    function openFancybox() {
        setTimeout(function() {
            j("#clickbanner").trigger('click');
        }, 500);

    };

    var visited = j.cookie('visited');
        if (visited == 'yes') {
            return false;
        } else {
            openFancybox();
        };
        j.cookie('visited', 'yes', {
            expires: 1
        });

    j("#clickbanner").click(function() {
        j.fancybox({
            href: this.href,
            type: "image",
            maxWidth: 750,
            maxHeight: 502
        });
        return false;
    });
});

It turns out the problem derived from the script tag path not being properly configured. 原来是由于脚本标记路径配置不正确而产生的问题。 As you can see in the image below, the pages are nested in folders and would need to be marked accordingly to get to the scripts. 如下图所示,页面嵌套在文件夹中,需要相应地进行标记才能进入脚本。

So <script type="text/javascript" src="../../../assets/javascript/ya_jquery.fancybox.ready.function.js"></script> as an example did the trick! 因此,以<script type="text/javascript" src="../../../assets/javascript/ya_jquery.fancybox.ready.function.js"></script>为例就可以了!

Strange thing was, I wasn't getting an error in the console saying I was missing the scripts. 奇怪的是,我没有在控制台中看到我缺少脚本的错误。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM