How to get the user's location from within a Chrome extension?
<p>I've created an extension and I'm trying to get the user's location so I can display it to them.</p>

<p>I've tried adding this code:</p>

<pre><code>var x = document.getElementById("ua");
function getLocation() {
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(showPosition);
    } else {
        x.innerHTML = "Unavailable.";
    }
}
function showPosition(position) {
    x.innerHTML = "Latitude: " + position.coords.latitude + 
    "&lt;br&gt;Longitude: " + position.coords.longitude; 
}
</code></pre>

<p>But nothing comes up in the extension, any advice? I'm also trying to avoid using the Chrome location API as it is only available on the Dev Channel.</p>