以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  AppendCookie  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=189082)

--  作者:zhenghangbo
--  发布时间:2023/11/9 15:06:00
--  AppendCookie
路径a.html 下的a.js里面使用了如下代码,使用submitAjaxFileds到\'scanjg.html\'返回的数据放到id为P1元素处在a页面显示。
    var result= submitAjaxFileds(\'scanjg.html\',\'\',\'id1\',\'id2\',false);
    if(result){
        var vals=result
        document.getElementById("p1").innerHTML=vals;
    }

scanjg.html里面使用
    wb.AppendCookie("b", “abc”)  )

为什么从a.html跳转到其他页面读取不到这Cookie?

--  作者:有点蓝
--  发布时间:2023/11/9 15:13:00
--  
ajax是无法直接返回cookie的。

需要自行处理,稍微有点麻烦,步骤:
1、在scanjg.html页面里把cookie值当做普通数据返回
2、js接收的result里把cookie值解析出来
3、使用js把解析的值添加到浏览器cookie里:https://www.baidu.com/s?wd=js%E6%B7%BB%E5%8A%A0cookie

--  作者:zhenghangbo
--  发布时间:2023/11/9 15:20:00
--  
能让其他页面访问到,添加到浏览器还得考虑跨域吧
--  作者:有点蓝
--  发布时间:2023/11/9 15:25:00
--  
同一个地址的的网页,不需要考虑这些东西