次のコードを使用して、経度と緯度のデータを 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" は正しく読み込まれますが、次の 2 つの "Latitude & Longitude" はエラーをスローします。
オブジェクトはプロパティまたはメソッド「cookie」をサポートしていません
どうしてこれなの?