澄清代号中的BrowserComponent execute(String javaScript)方法 [英] Clarification on Codename One's BrowserComponent execute(String javaScript) method

查看:39
本文介绍了澄清代号中的BrowserComponent execute(String javaScript)方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

BrowserComponent类中有一个"execute(String javaScript)"方法.您能解释一下这是如何工作的吗?

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

何时执行JavaScript-页面和任何外部.js文件完全加载后?

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

如果我传递一个字符串来执行外部.js文件中的方法,这行得通吗?

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

谢谢!

推荐答案

BrowserComponent.execute(String)将在您创建浏览器时在浏览器的当前页面中执行提供JS代码段.称呼.如果您的代码段引用了尚未加载的内容,则javascript将导致错误.

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.

如果要确保在运行代码段之前已完成页面的加载,则需要提供自己的检查.如果您在浏览器组件的onLoad事件中执行js,则该页面将被加载.页面中的所有< script> 标记也应该在那时加载(只要它们没有异步加载).

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).

这篇关于澄清代号中的BrowserComponent execute(String javaScript)方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆