Whats wrong with this? Please help me. I dont really understand how to do that | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 11

Whats wrong with this? Please help me. I dont really understand how to do that

<!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <p id="Position" onload="getLocation()">Position</p> </body> </html> <srcipt> var x=document. getElementById("Position"); function getLocation() { if (navigator.geolocation) { navigator.geolocation. getCurrentPosition(showPosition); } else { x.innerHTML="Geolocation is not supported by this browser."; } } </script>

20th Oct 2017, 1:06 PM
Jerremia Bryan
Jerremia Bryan - avatar
6 Answers
+ 16
owh ... now I understand why this does not work .... thanks @ESDETE, you are very kind to help answer my question .... sorry if I can not give you an upvote, because my account is still not verified
21st Oct 2017, 12:12 PM
Jerremia Bryan
Jerremia Bryan - avatar
+ 14
Oh, my God. I was less conscientious with my work. thanks a lot @ESDETE ^_^....i will fix it
21st Oct 2017, 10:33 AM
Jerremia Bryan
Jerremia Bryan - avatar
+ 12
and now, how does it work? it doesn't work on my divice.....is there any less?
21st Oct 2017, 11:07 AM
Jerremia Bryan
Jerremia Bryan - avatar
+ 1
Hey Bryan, - start tag "<srcipt>" instead of "<script>" :) - the onload-event doesn't work with paragraph-elements. - no function for "showPosition" esdete <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body onload="getLocation()"> <p id="Position">Position</p> <script> var x=document.getElementById("Position"); function getLocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition); } else { x.innerHTML="Geolocation is not supported by this browser."; } } function showPosition(position) { x.innerHTML = "Latitude: " + position.coords.latitude + "<br>Longitude: " + position.coords.longitude; } </script> </body> </html>
21st Oct 2017, 8:58 AM
esdete.
esdete. - avatar
+ 1
Oh okay, it doesn't work on unsecured HTTP: "As of Chrome 50, the Geolocation API will only work on secure contexts such as HTTPS. If your site is hosted on an non-secure origin (such as HTTP) the requests to get the users location will no longer function."
21st Oct 2017, 11:34 AM
esdete.
esdete. - avatar
0
Hello
30th Jan 2021, 2:17 PM
ftoort 09
ftoort 09 - avatar