Note that there are some explanatory texts on larger screens.

plurals
  1. POGeolocation using PhoneGap on Android works only on index.html
    text
    copied!<p>I'm trying to use geolocation using PhoneGap API doc, geolocation works on the index.html but when I try to use the same function in a different page it doesn't work.</p> <p><a href="http://docs.phonegap.com/en/1.8.1/cordova_geolocation_geolocation.md.html#Geolocation" rel="nofollow">http://docs.phonegap.com/en/1.8.1/cordova_geolocation_geolocation.md.html#Geolocation</a></p> <p>This is the JS I'm using.</p> <p>This is the button I'm using to get to the other page.</p> <p>I'm also using jQuery Mobile.</p> <pre><code> &lt;a href="test.html" data-theme="b" data-icon="plus"&gt;Add category&lt;/a&gt;&lt;/li&gt; </code></pre> <p>here is the head of test.html</p> <pre><code>&lt;meta charset="utf-8" /&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1" /&gt; &lt;title&gt;&lt;/title&gt; &lt;link rel="stylesheet" href="styles/jquery.mobile-1.1.0.min.css" /&gt; &lt;link rel="stylesheet" href="styles/jquery.mobile.structure-1.1.0.min.css" /&gt; &lt;link rel="stylesheet" href="styles/jquery.mobile.theme-1.1.0.min.css" /&gt; &lt;link rel="stylesheet" href="styles/my.css" /&gt; &lt;script src="scripts/jquery-1.7.2.min.js"&gt;&lt;/script&gt; &lt;script src="scripts/jquery.mobile-1.1.0.min.js"&gt;&lt;/script&gt; &lt;script src="scripts/cordova-1.8.1.js"&gt;&lt;/script&gt; &lt;script&gt; // Wait for Cordova to load // document.addEventListener("deviceready", onDeviceReady, false); var watchID = null; // Cordova is ready // function onDeviceReady() { // Throw an error if no update is received every 30 seconds var options = { timeout: 10000 }; watchID = navigator.geolocation.watchPosition(onSuccess, onError, options); } // onSuccess Geolocation // function onSuccess(position) { var element = document.getElementById('geolocation'); element.innerHTML = 'Latitude: ' + position.coords.latitude + '&lt;br /&gt;' + 'Longitude: ' + position.coords.longitude + '&lt;br /&gt;' + '&lt;hr /&gt;' + element.innerHTML; } // onError Callback receives a PositionError object // function onError(error) { alert('code: ' + error.code + '\n' + 'message: ' + error.message + '\n'); } &lt;/script&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload