user6338533
user6338533

Reputation:

How does java script know what features a specific browser support?

We normally need to check for browser support when we want to use a feature, such as navigator.GeoLocation object.

But exactly where and how do they exist? A physical dll file or completely saved in memory when the browsrr is running? Thanks

Upvotes: 0

Views: 32

Answers (1)

Jay Dave
Jay Dave

Reputation: 147

You can use following packages

Here : https://modernizr.com/docs/#what-is-feature-detection

But want with GeoLocation use this type of code

// Try HTML5 geolocation
    if(navigator.geolocation) {
      navigator.geolocation.getCurrentPosition(function(position) {
        var pos = new google.maps.LatLng(position.coords.latitude,
                                         position.coords.longitude);

        var infowindow = new google.maps.InfoWindow({
          map: map,
          position: pos,
          content: 'Location found using HTML5.'
        });

        map.setCenter(pos);
      }, function() {
        handleNoGeolocation(true);
      });
    } else {
      // Browser doesn't support Geolocation
      handleNoGeolocation(false);
    }

Upvotes: 1

Related Questions