2

我正在尝试修改一些代码,以在用户第一次访问时将其引导至“创建帐户”挤压页面。我想我已经接近了,但我需要一点帮助。关于我哪里出错的任何建议?

<script type="text/javascript">
$(document).ready(function() {
    // check cookie
    var visited = $.cookie("visited")

    if (visited == null) {
        window.location = "content/content-article.asp?ArticleID=4998"
        $.cookie('visited', 'yes'); 
        alert($.cookie("visited"));         
    }

    // set cookie
    $.cookie('visited', 'yes', { expires: 10,000, path: '/' });
});

4

2 回答 2

3

好的 - 我一直在挖掘并找到了一个不同的脚本。这是以防其他人尝试做同样的事情:

<script type="text/javascript">
function redirect(){
var thecookie = readCookie('doRedirect');
if(!thecookie){window.location = 'http://yournetwork.com/splash';
}}function createCookie(name,value,days){if (days){var date = new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires = "; expires="+date.toGMTString();}else var expires = "";document.cookie = name+"="+value+expires+"; path=/";}function readCookie(name){var nameEQ = name + "=";var ca = document.cookie.split(';');for(var i=0;i < ca.length;i++){var c = ca[i];while (c.charAt(0)==' ') c = c.substring(1,c.length);if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);}return null;}window.onload = function(){redirect();createCookie('doRedirect','true','999');}

于 2012-06-01T18:17:17.037 回答
0

试试这个:

$(document).ready(function() {
    // check cookie
    var visited = $.cookie("visited")

    // set cookie
    $.cookie('visited', 'yes', { expires: 10,000, path: '/' });

    if (visited == null) {
        $.cookie('visited', 'yes'); 
        alert($.cookie("visited"));         
        window.location = "content/content-article.asp?ArticleID=4998"
    }
});

执行代码后将位置更改为另一个站点

于 2012-06-01T15:59:55.003 回答