aboutsummaryrefslogtreecommitdiff
path: root/files/de/web/api/filereader/onload/index.html
blob: 95dda3e59f312dbadc11cda059d5a01252f4b951 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
---
title: onload
slug: Web/API/FileReader/onload
tags:
  - Dateien
  - Lesen
translation_of: Web/API/FileReader/onload
---
<p>Das onload Event wird ausgelöst, wenn der Inhalt von <a href="/en-US/docs/Web/API/FileReader/readAsArrayBuffer">readAsArrayBuffer</a>, <a href="/en-US/docs/Web/API/FileReader/readAsBinaryString">readAsBinaryString</a>, <a href="/en-US/docs/Web/API/FileReader/readAsDataURL">readAsDataURL</a> or <a href="/en-US/docs/Web/API/FileReader/readAsText">readAsText</a> verfügbar ist.</p>

<h2 id="Beispiel">Beispiel</h2>

<pre class="brush:js; line-numbers  language-js"><code class="language-js">// Callback von einem &lt;input type="file" onchange="onChange(event)"&gt;
function onChange(event) {
  var file = event.target.files[0];
  var reader = new FileReader();
  reader.onload = function(event) {
    // Hier wird der Text der Datei ausgegeben
    console.log(event.target.result)
  };

  reader.readAsText(file);
}
</code></pre>