wb.AppendHTML("<script src='http://res.wx.qq.com/open/js/jweixin-1.4.0.js'></script>",True) '引入JS-SDK库
'在页面注入权限验证配置
Dim st As New Date(1970,1,1,8,0,0)
Dim appid As String = Vars("appid") '开发者ID
Dim timestamp As Integer = CInt((Date.Now - st).TotalSeconds()) '时间戳
Dim noncestr As String = Rand.NextString(16) '随机字符
Dim url As String = e.Request.URL.ToString '当前页面地址
Dim signature As String = Functions.Execute("GetJsSignature", noncestr, timestamp, url) '生成权限验证签名
Dim cfg As String = "wx.config({appId:'{0}',timestamp:{1},nonceStr:'{2}',signature:'{3}',jsApiList:['openLocation']});"
wb.InsertHTML("<script>" & CExp(cfg,appid,timestamp,noncestr,signature) & "</script>",True)
'wb.InsertHTML("<script>" & CExp(cfg,appid,timestamp,noncestr,signature) & "</script>")
With wb.AddButtonGroup("bt3","btg3",False)
.Add("btn11", "位置地图", "button") ’进入页面+点这个按钮,下面的alert没有反应;web开发者工具和服务器,都没有报错;
.Add("btn2s2", "视频教程", "submit","/shipin_guanli_shenhsj_lb_xq.htm")
End With
js代码:
wx.ready(function () {
alert("ok"); ’这个alert不能显示
if(document.getElementById('btn11')) {
alert("ok"); ’这个alert不能显示
var latitude; // 纬度,浮点数,范围为90 ~ -90(手机获得的纬度)
var longitude; // 经度,浮点数,范围为180 ~ -180。(手机获得的经度)
latitude = document.getElementById("latitude").value;
longitude = document.getElementById("longitude").value;
document.getElementById('btn11').onclick = function () {
wx.openLocation({ //获得坐标后,直接打开微信内置地图
latitude: latitude, // 纬度,浮点数,范围为90 ~ -90
longitude: longitude, // 经度,浮点数,范围为180 ~ -180。
//name: '', // 位置名
//address: '', // 地址详情说明
scale: 3, // 地图缩放级别,整形值,范围从1~28。默认为最大
//infoUrl: '' // 在查看位置界面底部显示的超链接,可点击跳转
});
}
}
}); //顶部到此,全部结束
wx.error(function (res) {
alert(res.errMsg);
});