0
我寫了一個腳本來檢查我的瀏覽器是否具有功能。如果我運行此我得到一個錯誤,geosuccess
是undefined
瀏覽器功能檢測錯誤使用(navigator.geoloction)
<!DOCTYPE HTML>
<html>
<head>
<title id="title"> code Issues </title>
</head>
<body>
//=================== testing the feature detection method by using geolocation =======================//
function geosuccess(position)
{
var cords = position.cords;
var latitude = position.latitude;
var longitude = postion.longitude;
var message = "You're at " + latitude + ", " + longitude
alert(message);
}
function geoError(errorObj)
{
alert(errorObj.message);
}
if(typeof navigator.geolocation != "undefined")
{
console.log("inside geolocation");
navigator.geolocation.getCurrentPosition(geoSuccess, geoError);
}
else
{
alert("thos page uses Geolocation and your browser doesn't support it");
}
//=================== End of testing the feature detection method by using geolocation =======================//
</script>
<h1>List Publishers Ltd.</h1>
<div class="book">
<h2>Sprout.</h2>
<p>A book by J. Daniel Bedford</p>
<a href="#">Read now.</a>
</div>
</body>
</html>
:下面的腳本產生錯誤。
我試圖調試腳本,我可以看到它無法檢測到功能geoSuccess(position)
。
我希望我不會錯過一個面向對象的概念,並且錯誤可能與瀏覽器有關。
你是完全正確的,我不相信我是那個盲人,非常感謝:) –