Script Publishing Issues

  • 1
  • Question
  • Updated 3 years ago
I'm having problems publishing the following script on my website. It is a Geolocation script that shows the users coordinates on the page. It works when "Previewing" the page but does not work when published. The script will ask if you will allow it to run and shows the GPS symbol in the search browser (Chrome), but does not display the result under the button. Any Ideas? Thanks!

Here is the script I want to use:

<!DOCTYPE html><html>
<body>
<p>Click the button to get your coordinates.</p>
<button onclick="getLocation();showPosition()">Find Location</button>
<p id="Wingmatefinder"></p>
<script>
var x = document.getElementById("Wingmatefinder");
function getLocation() {
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(showPosition, showError);
    } else { 
        x.innerHTML = "Geolocation is not supported by this browser.";
    }
}
function showPosition(position) {
    x.innerHTML = "Latitude: " + position.coords.latitude + 
    "<br>Longitude: " + position.coords.longitude;
}
function showError(error) {
    switch(error.code) {
        case error.PERMISSION_DENIED:
            x.innerHTML = "User denied the request for Geolocation."
            break;
        case error.POSITION_UNAVAILABLE:
            x.innerHTML = "Location information is unavailable."
            break;
        case error.TIMEOUT:
            x.innerHTML = "The request to get user location timed out."
            break;
        case error.UNKNOWN_ERROR:
            x.innerHTML = "An unknown error occurred."
            break;
    }
}
</script>
</body>
</html>
Photo of Logan Shamoon

Logan Shamoon

  • 6 Posts
  • 0 Reply Likes

Posted 3 years ago

  • 1
Photo of Jen

Jen

  • 206 Posts
  • 24 Reply Likes
Hello Logan,

Can you please share the site URL you're working on so we can take a look?  Thanks for your help!
Photo of Logan Shamoon

Logan Shamoon

  • 6 Posts
  • 0 Reply Likes
I'm still working on the site, but it's www.WingMateTags.yolasite.com
Thanks!
Photo of Logan Shamoon

Logan Shamoon

  • 6 Posts
  • 0 Reply Likes
Let me be more specific: http://wingmatetags.yolasite.com/LOST...

I'm testing two scripts, but it's the button that says "Find Location".
Photo of Mvikeli Mgobozi

Mvikeli Mgobozi, Official Rep

  • 30 Posts
  • 3 Reply Likes
Hi Logan,

Thanks for the clarification! I would like to continue assisting you with this, and have reached out to you via email. Please respond to that message so we may continue working with one another. Thanks!