以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  js创建cookie不成功  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=160656)

--  作者:zhangjian222200
--  发布时间:2021/2/9 22:08:00
--  js创建cookie不成功
1.页面代码:
Dim e As RequestEventArgs = args(0)
e.Resp

Dim sb As New StringBuilder
sb.AppendLine("<!DOCTYPE html>")
sb.AppendLine("<html lang=\'zh-cmn-Hans\'>")
sb.AppendLine("<head>")
    sb.AppendLine("<meta charset=\'utf-8\'>")
    sb.AppendLine("<meta name=\'viewport\' c>")
    sb.AppendLine("<link rel=\'stylesheet\' href=\'/weui/weui.min.css\'>")
    sb.AppendLine("<link rel=\'stylesheet\' href=\'/weui/weui.me.css\'>")
    sb.AppendLine("<link rel=\'stylesheet\' href=\'css/index.css\'>")
    sb.AppendLine("<title>本地交换-闲置物品交换使用</title>")
    sb.AppendLine("<script src=\'/weui/weui.me.js\'></script>")
    sb.AppendLine("<link rel=\'icon\' href=\'/abc.ico\' Type=\'image/x-icon\'>")
    检查确认,下面两个文件正常引入
    sb.AppendLine("<script src=\'https://res.wx.qq.com/open/js/jweixin-1.4.0.js\'></script>") \'引入JS-SDK库
    sb.AppendLine("<script src=\'./lib/ajaxform_index.js\'></script>") \'引入脚本文件
sb.AppendLine("</head>")

sb.AppendLine("<body onload()\'>")

******


2.ajaxform_index.js代码:
wx.ready(function () {
    var latitude; // 纬度,浮点数,范围为90 ~ -90(手机获得的纬度)
    var longitude; // 经度,浮点数,范围为180 ~ -180。(手机获得的经度)
    var speed; // 速度,以米/每秒计
    var accuracy; // 位置精度

    wx.getLocation({
       type: \'gcj02\', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入\'wgs84\'|\'gcj02\'
       success: function (res) {
       latitude = res.latitude; // 纬度,浮点数,范围为90 ~ -90
       longitude = res.longitude; // 经度,浮点数,范围为180 ~ -180。
       speed = res.speed; // 速度,以米/每秒计
       accuracy = res.accuracy; // 位置精度

       document.cookie = latitude + "=" + latitude;
       document.cookie = longitude + "=" + longitude; 
       
       alert("ok"); //这个ok不显示

       }
    }); 
})

3.下面是页面的cookie:没有上面js创建的2个cookie

图片点击可在新窗口打开查看此主题相关图片如下:0001.png
图片点击可在新窗口打开查看

[此贴子已经被作者于2021/2/9 22:09:38编辑过]

--  作者:有点蓝
--  发布时间:2021/2/9 22:22:00
--  
没看到有授权签名和调用wx.config配置sdk的代码:http://www.foxtable.com/mobilehelp/topics/0247.htm
--  作者:zhangjian222200
--  发布时间:2021/2/9 22:56:00
--  
成功了