I need to detect HTML5 Geolocation support using PHP so that I can load a backup JavaScript that supports Geolocation using IP Address.
How to do this with or without PHP.
Have you considered using Modernizr to detect the HTML5 support? This isn't PHP specific since it's done in JavaScript but you can use this snippet to load your backup file:
if (Modernizr.geolocation){
// Access using HTML5
navigator.geolocation.getCurrentPosition(function(position) { ... });
}else{
// Load backup file
var script = document.createElement('script');
script.src = '/path/to/your/script.js';
script.type = 'text/javascript';
var head = document.getElementsByTagName("head")[0];
head.appendChild(script);
}
(Based on http://www.modernizr.com/docs/#geolocation)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With