About the author

Photo of sanduhrs
sanduhrs

Firefox Gelolocation

Das ist ein echter Spaß! Seit Firefox 3.5 hat man per JavaScript Zugriff auf die GeoCoordinaten des Benutzers, sofern dieser das erlaubt.

Die folgenden Angaben sind ausgefüllt, wenn Firefox > v3.5 benutzt wird und der Browser-Dialog bestätigt wurde.

Latitude:
Longitude:

Der Code dazu sieht folgendermaßen aus:

<script>
showPosition = function (position) {
  var geo = $('.geo');
  var lat = position.coords.latitude;
  var lon = position.coords.longitude;

  $('.latitude', geo).html(lat);
  $('.longitude', geo).html(lon);
};
$(document).ready(function() {
  navigator.geolocation.getCurrentPosition(showPosition);
});
</script>

<div class="geo">
  Latitude: <span class="latitude"></span>
  Longitude: <span class="longitude"></span>
</div>

Weblinks

http://hacks.mozilla.org/2009/06/geolocation/

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

Website powered by lovely Drupal · Microformats · XML Feed · Valid XHTML, CSS · No www.