-
Notifications
You must be signed in to change notification settings - Fork 22.7k
/
Copy pathindex.md
44 lines (29 loc) · 963 Bytes
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
---
title: "TrustedScriptURL: toString() method"
short-title: toString()
slug: Web/API/TrustedScriptURL/toString
page-type: web-api-instance-method
browser-compat: api.TrustedScriptURL.toString
---
{{APIRef("Trusted Types API")}}{{AvailableInWorkers}}
The **`toString()`** method of the {{domxref("TrustedScriptURL")}} interface returns a string which may safely inserted into an [injection sink](/en-US/docs/Web/API/Trusted_Types_API#concepts_and_usage).
## Syntax
```js-nolint
toString()
```
### Parameters
None.
### Return value
A string containing the sanitized URL
## Examples
The constant `sanitized` is an object created via a Trusted Types policy. The `toString()` method returns a string to safely use to load a third party script.
```js
const sanitized = scriptPolicy.createScriptURL(
"https://example.com/my-script.js",
);
console.log(sanitized.toString());
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}