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

# evaluateJavaScript

APISummary
执行后台脚本逻辑。

## 语法

### Android

```java
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

```objc
- (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

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

## 兼容性

**Compatibility Table**

**Query:** `lynx-native-api.lynx-background-runtime.evaluate-java-script`

[Source](https://github.com/lynx-family/lynx-website/tree/main/packages/lynx-compat-data/lynx-native-api/lynx-background-runtime/evaluate-java-script.json)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| evaluate-java-script | Yes (3.1) | Yes (3.4) | Yes (3.1) | No | No | No |

**`evaluate-java-script`**

evaluate background runtime script

**Specifications:**

