Wednesday, January 3, 2018

javascript how to allow geolocation in web page

javascript how to allow geolocation in web page




javascript - how to allow geolocation in web page -

i have been trying run code latitude , longitude. ie browser shows message geolocation services not supported, , chrome says this page has been blocked tracking location after set location setting in chrome allow sites track. please help.

<html> <head></head> <body> <input type="button" id="btnsearch" value="search" onclick="dosomething();"/> <script> function dosomething(){ if (navigator.geolocation) { navigator.geolocation.getcurrentposition(handle_geolocation_query); function handle_geolocation_query(position) { alert(lat: + position.coords.latitude + + lon: + position.coords.latitude); } } else { alert("im sorry, geolocation services not supported browser."); } } </script> </body> </html>

change scope of handle_geolocation_query() outer, , should work. works on ie , firefox after changes.

<html> <head></head> <body> <input type="button" id="btnsearch" value="search" onclick="dosomething();"/> <script> function dosomething(){ if (navigator.geolocation) { navigator.geolocation.getcurrentposition(handle_geolocation_query); } else { alert("im sorry, geolocation services not supported browser."); } } function handle_geolocation_query(position) { alert(lat: + position.coords.latitude + + lon: + position.coords.latitude); } </script> </body> </html>

javascript html5 geolocation

go to link download
download
alternative link download

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.