Getting and Printing / Displaying / Echoing Exact GPS Coordinates Upon Web Page Refresh With HTML5 and PHP

Getting and Printing / Displaying / Echoing Exact GPS Coordinates Upon Web Page Refresh With HTML5 and PHP

I have tried about 100 different ways to get this to work and it will NEVER work no matter what I throw at it. When I try using the official WW3 HTML5 GeoLocation built in functions I am able to get the GPS Longitude and GPS Latitude numbers, but for some reason it ONLY works with a button.

This is resource I am using:
https://www.w3schools.com/html/html5_geolocation.asp

What am I trying to do ?
I am trying to get the exact GPS coordinates Longitude, Latitude and Altitude by using the built in HTML5 functions ONLY and make it report the GPS coordinates to a log file as well as print them to the web page upon every reload of the web page document. I don’t know how to make it work. JavaScript never attaches the information to a variable and none of the variables can be called upon later on down the script. Constants do NOT work. None of it works unless it’s attached to a button as shown in the HTML5 demonstration page.

Can anyone show me how to make this work ?

None of it works. Every resource I came across on Google does not work.