For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt, and this page is available as Markdown at /next/zh/api/lynx-native-api/lynx-background-runtime/evaluate-java-script.md.
Lynx
  • 简体中文
  • evaluateJavaScript

    执行后台脚本逻辑。

    语法

    Android

    public void evaluateJavaScript(String url, @NonNull String sources);
    public void evaluateTemplateBundle(String url, @NonNull TemplateBundle bundle, @NonNull String js_file);

    参数说明

    • url: 脚本唯一标识。
    • sources: 脚本内容。
    • bundle: 预解析的 TemplateBundle,包含脚本。
    • js_file: Bundle 内关联的 JS 文件名。

    iOS

    - (void)evaluateJavaScript:(NSString *)url withSources:(NSString *)sources;
    - (void)evaluateTemplateBundle:(NSString *)url
                       widthBundle:(LynxTemplateBundle *)bundle
                        withJSFile:(NSString *)jsFile;

    参数说明

    • url: 脚本唯一标识。
    • sources: 脚本内容。
    • bundle: 预解析的 LynxTemplateBundle,包含脚本。
    • jsFile: Bundle 内关联的 JS 文件名。

    Harmony

    evaluateJavaScript(url: string, sources: string): void;
    evaluateBundleScript(url: string, bundle: TemplateBundle, jsFileName: string): void;

    兼容性

    LCD tables only load in the browser

    除非另有说明,本项目采用知识共享署名 4.0 国际许可协议进行许可,代码示例采用 Apache License 2.0 许可协议进行许可。