web location -> java script error

I have the most simple location app possible. With one single webpage with a DeviceLocation control called ‘weblocator’ with the events ‘devicelocation’ and ‘error’ resulting in a message box. In the open event of the webpage I have weblocator.requestdevicelocation. That’s all,
When compiling it crashes with an apparent Javascript error. (I have the latest Javascript and compiled it with Sarfati as well as Firefox as browsers both resulted in this behaviour). Xojo’s example ‘MapViewer’ doesn’t start up either. Please what can be wrong (maybe it is related to SSL???)

The error reads:
Could not execute returned javascript: undefined is not an object (evaluating ‘Xojo.controls[‘ZNFAjcYb’].getDeviceLocation’)
Source: var langdir = document.getElementsByTagName(‘body’)[0]; if(langdir) { langdir.removeAttribute(‘dir’); }
var langdir = document.getElementsByTagName(‘body’)[0]; if(langdir) { langdir.setAttribute(‘lang’,‘en’); }
Xojo.controls[‘ZNFAjcYb’].getDeviceLocation(30000,60000, false);
new devicelocation(‘ZNFAjcYb’,[‘Close’,‘DeviceLocation’,‘DoubleClick’,‘Error’,‘GotFocus’,‘KeyPressed’,‘LostFocus’,‘MouseDown’,‘MouseEnter’,‘MouseExit’,‘MouseMove’,‘MouseUp’,‘Open’,‘Shown’]);
new frameworkObject(‘gCrPN8LU’,[‘Close’,‘Open’,‘Shown’]);
document.title = “Untitled”;

Try moving your code into the Shown event.

Controls are not existing yet in Open event.

Thanks Olivier, that solved the problem of crashing but now I get the message that
‘Origin does not have permission to use Geolocation service’

I read somewhere that safari does not allow location services if you don’t use a secure connection. If I use Firefox the normal equation is asked if the user permits location services to be used,
What is the simplest way (I am a hobbyist not a corporation) to turn my app into a secure app?

I think you’d better start a new thread for this, it’s not a javascript error anymore.
I’m not sure there is a ‘simple way’ to do this. Geolocation requires you to use SSL/HTTPS.

Olivier, You are right I better start a new conversation. It is still the web as target. Thanks for solving the crash.