Script Error - Geolocation - reference

Hi All,
Was doing a action-script for geolocation as shown below

Once I tested it, a error on document type.

The script is based on HTML 5 Geolocation, HTML Geolocation API which works on normal browser.

Please advise. Thanks.

I think you need to verify webpage is fully loaded in js before your script :