0
我有一個函數提醒我當前的經度和緯度。 但是,我不想提醒此值。 相反,我想在點擊「潘」將警報值傳遞到輸入字段
<html>
<script>
function getPosition() {
var options = {
enableHighAccuracy: true,
maximumAge: 3600000
}
var watchID = navigator.geolocation.getCurrentPosition(onSuccess, onError, options);
function onSuccess(position) {
alert('Latitude: ' + position.coords.latitude + '\n' +
'Longitude: ' + position.coords.longitude + '\n');
};
function onError(error) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
}
</script>
<body>
<div data-role="page" data-theme="b">
<div data-role="header">
<h1>Test</h1>
</div>
</div>
<br>
<br>
<label for="Location">Location:</label>
<button onclick = "getPosition()" id = "getPosition">PAN</button>
<input type="text" name="Location" id="location">
<br>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
</body>
</html>
感謝詹姆斯,它像一個魅力工作。 – Zesty