【发布时间】:2017-02-03 12:42:02
【问题描述】:
当我们想要使用一个特性时,我们通常需要检查浏览器是否支持,例如 navigator.GeoLocation 对象。
但它们究竟在哪里以及如何存在?浏览器运行时是物理dll文件还是完全保存在内存中? 谢谢
【问题讨论】:
标签: html google-chrome browser
当我们想要使用一个特性时,我们通常需要检查浏览器是否支持,例如 navigator.GeoLocation 对象。
但它们究竟在哪里以及如何存在?浏览器运行时是物理dll文件还是完全保存在内存中? 谢谢
【问题讨论】:
标签: html google-chrome browser
您可以使用以下软件包
这里:https://modernizr.com/docs/#what-is-feature-detection
但是想在 GeoLocation 中使用这种类型的代码
// 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);
}
【讨论】: