Clarification on Codename One's BrowserComponent execute(String javaScript) method

爱⌒轻易说出口 提交于 2019-12-10 11:39:09

问题


There is the "execute(String javaScript)" method in the BrowserComponent class. Could you please explain how this work?

When would the JavaScript be executed - after the page and any external .js files are fully loaded?

If I pass a string which is to execute a method in an external .js file, would this work?

Thanks!


回答1:


BrowserComponent.execute(String) will execute the provide JS snippet in the current page of the browser at the time that you make the call. If your snippet references things that aren't loaded yet, then the javascript will result in an error.

If you want to ensure that the page has finished loading before your snippet is run, then you'll need to provide your own checks. If you execute your js inside the onLoad event of the browser component, then the page will have been loaded. Any <script> tags in the page should also have loaded by that time (as long as they aren't loaded async).



来源:https://stackoverflow.com/questions/43539689/clarification-on-codename-ones-browsercomponent-executestring-javascript-meth

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!