1

好的,这是我的代码

<html>
<head>
<title></title>
<body>
<script>
<!--
/* 
Cookie Redirect. Written by PerlScriptsJavaScripts.com
Copyright http://www.perlscriptsjavascripts.com 
Free and commercial Perl and JavaScripts     
*/

// page to go to if cookie exists
go_to = "http://www.cookieisthere.com";

// number of days cookie lives for
num_days = 365;
function ged(noDays){
    var today = new Date();
    var expr = new Date(today.getTime() + noDays*24*60*60*1000);
    return  expr.toGMTString();
}

function readCookie(cookieName){
    var start = document.cookie.indexOf(cookieName);
    if (start == -1){ 

    } else {
        window.location = go_to;
    }
}

readCookie("seenit");
// -->
</script>

</body>
</html>

此页面将通过 iframe 加载到页面上...如果 cookie 是他们的,我希望父窗口转到http://www.cookieisthere.com而不是原始页面。在阅读了一些内容之后,有人说在链接所在的位置使用 _top,但我不知道该怎么做。非常感谢所有帮助:)

4

1 回答 1

0

试试这个

<html>
<head>
<title></title>
<body>
<script>
<!--
/* 
Cookie Redirect. Written by PerlScriptsJavaScripts.com
Copyright http://www.perlscriptsjavascripts.com 
Free and commercial Perl and JavaScripts     
*/

// page to go to if cookie exists
go_to = "http://www.cookieisthere.com";

// number of days cookie lives for
num_days = 365;
function ged(noDays){
    var today = new Date();
    var expr = new Date(today.getTime() + noDays*24*60*60*1000);
    return  expr.toGMTString();
}

function readCookie(cookieName){
    var start = document.cookie.indexOf(cookieName);
    if (start == -1){ 

    } else {
        window.top.location = go_to;
    }
}

readCookie("seenit");
// -->
</script>

</body>
</html>
于 2013-09-07T23:40:55.073 回答