小编eag*_*e12的帖子

在Android浏览器中禁用cookie无法正常工作

我正在运行Android Honeycomb 3.2.1,我无法让浏览器停止接受cookie.我有以下代码:

first.html:

<!DOCTYPE html>
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script type="text/javascript" src="cookie.js"></script>
        <script type="text/javascript">
            setCookie('testing','test cookie',365);
            window.location.href = 'second.html';
        </script>
    </head>
    <body>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

second.html:

<!DOCTYPE html>
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script type="text/javascript" src="cookie.js"></script>
        <script type="text/javascript">
            var temp = getCookie('testing');
            alert(temp);
        </script>

    </head>
    <body>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

cookie.js:

function setCookie(c_name,value,exdays)
{
    var exdate=new Date();
    exdate.setDate(exdate.getDate() + exdays);
    var c_value=escape(value) + ((exdays==null) ? "" : ";     expires="+exdate.toUTCString());
    document.cookie=c_name + "=" + c_value;
}

function getCookie(c_name) …
Run Code Online (Sandbox Code Playgroud)

javascript cookies android mobile-safari

6
推荐指数
1
解决办法
415
查看次数

标签 统计

android ×1

cookies ×1

javascript ×1

mobile-safari ×1