0
ブラウザに機能があるかどうかを確認するスクリプトを作成しました。次のスクリプトはエラーを生成します(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
がundefined
するエラーが発生します。
私はスクリプトをデバッグしようとしましたが、私はそれが機能geoSuccess(position)
を検出できないことがわかります。
私はオブジェクト指向のコンセプトが欠けていないと思いますが、エラーはおそらくブラウザーに関連するものです。
あなたはまったく正しいと私は、私はその盲目であるとは思わない、たくさんの:) –