Control unavailable in browser

There is an problem caused by “shown order” that appears when you are using a components like wrapper or Xojo-classes extended with a JavaScript to do something on the client side. You can use “ControlAvailableInBrowser()” to start a piece of code, but what if the answer is “False”. Usually the code will not run at all.

Here is a trick I wanted to share. assume your JavaScript code is in a variable called codeJS.
Your usual “ExecuteJavascript(codeJS)” may cause various “nil object” type of exceptions if component is not (yet) created. To avoid you may actually use

codeJS = "setTimeout(function(){ " + codeJS+ "}, 50);"

and then

ExecuteJavascript(codeJS)

where the 50 milliseconds timeout will actually fire off after everything is finished, thus all components are in your browser.
It is tested and works!

I would appreciate further suggestions.

Usually what ContrilAvailableInBrowser means is that you’re still in the first volley of initialization and that you should be applying the changes directly to the HTML, CSS or JavaScript initialization. Once that function returns true, you are free to call executeJavascript to directly manipulate the dom.

FWIW, using a number like 50 will only get you so far. Some of the initialization is asynchronous and your code could still run before the control is ready.

50 ms in terms of Web is nothing. A regular round trip is 150 ms.

It is quite possible that what is described works fine local, but chances are it will not be reliable once on a host on the Internet.

Please stop spreading this misinformation. Response time changes by user, location, and network connection.
The first result on Google says that’s not accurate anyway

In practice, indeed, response time varies. 150 ms is an average ping on a decent DSL. Of course with bad network it can be much more. And probably shorter on a better connection. My point was that 50 ms is way too little for a reliable result.

BTW, it is fairly easy to type ping <url address of the server> in the terminal, or the Windows Command prompt.

EDIT : NJP - removed name calling portions

If you want to continue this topic please start a new thread. And remember to be nice to each other! We want this forum to continue to be a collaborative environment.