我正在尝试使用以下代码将经度和纬度数据加载到Cookie中:
$.cookie('test', 'test');
var test = true;
function PageLoaded() {
if (test) {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(success_handler, error_handler, {
enableHighAccuracy: true
});
test = false;
}
}
}
function success_handler(position) {
latitude = position.coords.latitude;
longitude = position.coords.longitude;
accuracy = position.coords.accuracy;
document.getElementById("tbLat").value = latitude;
document.getElementById("tbLon").value = longitude;
$.cookie('Latitude', latitude);
$.cookie('Longitude', longitude);
}
function error_handler() {
document.write('This browser does not support location awareness or you have declined to allow it to view your location.');
}
我正在加载JQuery.Cookie.js插件。 第一个cookie“test”正确加载但第二个“Latitude& Longitude”抛出错误
Object不支持属性或方法'cookie'
为什么会这样?