You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### Creating a URL representing the contents of a typed array
59
59
60
-
The following code creates a JavaScript [typed array](/en-US/docs/Web/JavaScript/Guide/Typed_arrays) and creates a new `Blob` containing the typed array's data. It then calls {{DOMxRef("URL/createObjectURL_static", "URL.createObjectURL()")}} to convert the blob into a {{glossary("URL")}}.
60
+
The following example creates a JavaScript [typed array](/en-US/docs/Web/JavaScript/Guide/Typed_arrays) and creates a new `Blob` containing the typed array's data. It then calls {{DOMxRef("URL/createObjectURL_static", "URL.createObjectURL()")}} to convert the blob into a {{glossary("URL")}}.
61
61
62
-
#### HTML
63
-
64
-
```html
62
+
```html live-sample___url-from-array
65
63
<p>
66
64
This example creates a typed array containing the ASCII codes for the space
67
65
character through the letter Z, then converts it to an object URL. A link to
68
66
open that object URL is created. Click the link to see the decoded object URL.
69
67
</p>
70
68
```
71
69
72
-
#### JavaScript
73
-
74
70
The main piece of this code for example purposes is the `typedArrayToURL()` function, which creates a `Blob` from the given typed array and returns an object URL for it. Having converted the data into an object URL, it can be used in a number of ways, including as the value of the {{HTMLElement("img")}} element's [`src`](/en-US/docs/Web/HTML/Element/img#src) attribute (assuming the data contains an image, of course).
75
71
76
-
```js
72
+
```js live-sample___url-from-array
77
73
functionshowViewLiveResultButton() {
78
74
if (window.self!==window.top) {
79
75
// Ensure that if our document is in a frame, we get the user
@@ -103,18 +99,15 @@ if (!showViewLiveResultButton()) {
0 commit comments