每当我使用400
时出现Visual Studio Code
错误,但当我使用Brackets
时,它的工作正常。
导致此错误的原因是什么?如何解决?
提前谢谢你:)
<script>
var watcher;
var geoLocator;
window.onload = function() {
geoLocator = window.navigator.geolocation;
var posOptions = {
enableHighAccuracy: true,
timeout: 45000
};
watcher = geoLocator.watchPosition(successPosition, errorPosition, posOptions);
}
function successPosition(pos) {
var sp = document.createElement("p");
sp.innerText = "Latitude: " + pos.coords.latitude + " Longitude: " + pos.coords.longitude;
document.getElementById("geoResults").appendChild(sp);
geoLocator.clearWatch(watcher);
}
function errorPosition(err) {
var sp = document.createElement("p");
sp.innerText = "error: " + err.message; + " code:" + err.code;
document.getElementById("geoResults").appendChild(sp);
}
</script>