title: Determining whether html5 geolocation function is available AND whether it knows where you are?
body: <p>I'm experimenting with HTML5 geolocation, and embedded a small test script into a page to return my present co-ordinates.</p>
  
  <p>The current application I have in mind for using this is as a 'nice to have' feature on site i'm working on - it includes a 'find my nearest' lookup on some locations, and I figured that if you had a location aware device, I could easily include 'to my current location' alongside the normal 'to my postal/zip code'.  I'm not interested in loading a bunch of extra libraries and fallbacks for such a small and non-essential feature.  If you have a capable device, great, if not, you won't ever see the option.</p>
  
  <p>So I tried the script on an iPad, and as expected - I was prompted for permission to use my present location, to which I agreed, and my test script returned my present location.  Total win.</p>
  
  <p>I tried the same on my desktop, since i'm using Firefox 4 and its a HTML5 compliant browser.  It asked me if I wanted to share my location, and then promptly returned the error that it didn't know my location (because its a desktop computer and has no GPS).  I thought this rendered the original question of 'do you want to share your location' somewhat pointless - it could needlessly annoy people who might have thought they could use a feature that they in fact can't.</p>
  
  <p>So, what is a reliable technique to detect if:</p>
  
  <blockquote>
    <p>a) The browser can access HTML5 geolocation </p>
    
    <p><strong>AND</strong> </p>
    
    <p>b) The browser knows or can find out what the users location is.</p>
  </blockquote>
  
  <p>Without actually calling the geolocation function beforehand, and asking the user an annoying, and unnecessary question?</p>
  
  <p>For a) i'm simply using:</p>
  
  <pre><code>if (navigator.geolocation) {
       navigator.geolocation.getCurrentPosition(showCoords,handleGeoErrors);    
  }
  </code></pre>
  
  <p>But for b) the only answer I have involves having called getCurrentPosition, which triggers the question to the user.</p>
  
  <p>Any thoughts on this, anyone?</p>