javascript - how to allow geolocation in web page -
I am trying to run this code for latitude and longitude. My IE browser shows this message that geographic location services are not supported, and chrome says 'even after this page has been blocked from tracking your location' even after I set the location setting in Chrome all sites Allow me to track. help please.
& lt; Html & gt; & Lt; Top & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Input type = "button" id = "btn search" value = "search" onclick = "doSomething ();" /> & Lt; Script & gt; Function doSomething () {if (navigator.clocation) {navigator.geolocation.getCurrentPosition (handle_geolocation_query); Function handle_jolocation_corea (status) {warning ('wave:' + position.coords.latitude + '' + 'loan:' + position.coords.latitude); }} And {warnings ("I'm sorry, but geolocation services are not supported by your browser."); }} & lt; / Script & gt; & Lt; / Body & gt; & Lt; / Html & gt;
Change the scope of the handle_geolocation_query () to the external, and it should work. After this change works on my IE and Firefox.
& lt; Html & gt; & Lt; Top & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Input type = "button" id = "btn search" value = "search" onclick = "doSomething ();" /> & Lt; Script & gt; Function doSomething () {if (navigator.clocation) {navigator.geolocation.getCurrentPosition (handle_geolocation_query); } And {warnings ("I'm sorry, but geolocation services are not supported by your browser."); }} Function handle_geolocation_query (status) {warning ('Lat:' + position.coords.latitude + '' + 'lawn:' + position.coords.latitude); } & Lt; / Script & gt; & Lt; / Body & gt; & Lt; / Html & gt;
Comments
Post a Comment