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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
---
title: Konsole Bild
slug: Tools/Web_Konsole/Hilfe
tags:
- Anfänger
- Befehle
- Beispiele
- Debugging
- Deutsch
- Firefox
- Konsole
- Maxi
- Übersetzung
translation_of: Tools/Web_Console/Helpers
---
<div>{{ToolsSidebar}}</div><h2 id="Die_Befehle">Die Befehle</h2>
<p><span id="result_box" lang="de"><span class="hps">Die</span> <span class="hps">von der</span> <span class="hps">Web Console</span> <span class="hps">bereitgestellt</span> <span class="hps">JavaScript</span> <span class="hps">Kommandozeile</span> <span class="hps">bietet ein paar</span> <span class="hps">eingebauten</span> <span class="hps">Hilfsfunktionen,</span> <span class="hps">bestimmte Aufgaben</span> <span class="hps">zu erleichtern.</span><br>
<br>
<strong><span class="hps">$ ()</span></strong><br>
<span class="hps">Sucht nach einer</span> <span class="hps">CSS-Selektor</span><span>-String</span><span>, der Rückkehr</span> <span class="hps">auf das erste Element</span><span>, das</span> <span class="hps">passt.</span> <span class="hps">Entspricht</span> <span class="atn hps">{</span><span class="atn">{</span><span>domxref</span> <span class="atn hps">(</span><span class="atn hps">"</span><span>document.querySelector</span> <span class="hps">()")</span><span>}}</span> <span class="hps">oder</span> <span class="hps">ruft die</span> <span class="hps">$ -Funktion</span> <span class="hps">in</span> <span class="hps">der Seite</span><span>,</span> <span class="hps">wenn es vorhanden ist</span><span>.</span><br>
<strong><span class="atn hps">$$ (</span><span>)</span></strong><br>
<span class="hps">Sucht nach einer</span> <span class="hps">CSS-Selektor</span><span>-String</span><span>, der Rückkehr</span> <span class="hps">eine</span> <span class="hps">Liste von DOM</span><span>-Knoten</span> <span class="hps">zusammenpasst.</span> <span class="hps">Dies</span> <span class="hps">ist eine Abkürzung für</span> <span class="atn hps">{</span><span class="atn">{</span><span>domxref</span> <span class="atn hps">(</span><span class="atn hps">"</span><span>document.querySelectorAll</span> <span class="hps">()")</span><span>}}</span><span>.</span><br>
<strong><span class="hps">$ 0</span></strong><br>
<span class="hps">Das aktuell</span> <span class="hps">geprüft</span> <span class="hps">Element in der</span> <span class="hps">Seite</span><span>.</span><br>
<strong><span class="hps">$ x</span> <span class="hps">()</span></strong><br>
<span class="hps">Wertet</span> <span class="hps">einen XPath-Ausdruck</span> <span class="hps">und</span> <span class="hps">gibt ein Array von</span> <span class="hps">passenden</span> <span class="hps">Knoten.</span><br>
<strong><span class="atn hps">keys (</span><span>)</span></strong><br>
<span class="hps">Für</span> <span class="hps">ein gegebenes Objekt</span><span> </span><span class="hps">wird eine Liste</span> <span class="hps">der Schlüsseln</span> <span class="hps">(oder</span> <span class="hps">Eigenschaftsnamen</span><span>)</span> <span class="hps">für das Objekt</span><span> angezeigt.</span> <span class="hps">Dies</span> <span class="hps">ist eine Abkürzung für</span> <span class="hps">Object.keys</span><span>.</span><br>
<strong><span class="hps">values</span> <span class="hps">()</span></strong><br>
<span class="hps">Für</span> <span class="hps">ein gegebenes Objekt</span><span> </span></span>wird<span lang="de"> <span class="hps">eine Liste der</span> <span class="hps">Werte</span> <span class="hps">für das Objekt</span><span> zurückgegeben;</span> <span class="hps">dient als</span> <span class="hps">Ergänzung zu</span> <span class="atn hps">keys (</span><span>)</span><span>.</span><br>
<strong><span class="hps">clear ()</span></strong><br>
<span class="hps">Löscht den</span> <span class="hps">Ausgabebereich</span><span> der Konsole.</span><br>
<strong><span class="hps">inspect</span> <span class="hps">()</span></strong><br>
<span class="hps">Da</span> <span class="hps">ein Objekt</span> <span class="hps">öffnet</span> <span class="hps">den Objektinspektor</span> <span class="hps">für das Objekt</span><span>.</span><br>
<strong><span class="hps">pprint</span> <span class="hps">()</span></strong><br>
<span class="hps">Formatiert</span> <span class="hps">den angegebenen Wert</span> <span class="hps">in lesbarer</span> <span class="hps">Weise</span><span>;</span> <span class="hps">Dies</span> <span class="hps">ist nützlich für die</span> <span class="hps">Dumping</span> <span class="hps">den Inhalt der</span> <span class="hps">Objekte und Arrays</span><span>.</span><br>
<strong><span class="hps">help</span><span class="hps">()</span></strong><br>
<span class="hps">Zeigt Hilfetext</span> <span class="hps">.</span> <span class="hps">Eigentlich</span> <span class="hps">in einem schönen</span> <span class="hps">Beispiel für</span> <span class="hps">Rekursion</span><span>,</span> <span class="hps">es wird Sie</span> <span class="hps">zu dieser Seite</span> <span class="hps">zu bringen.</span><br>
<strong><span class="hps">cd</span> <span class="hps">()</span></strong><br>
<span class="hps">Schalten Sie</span> <span class="hps">JavaScript</span> <span class="hps">Auswertung</span> <span class="hps">Kontext</span> <span class="hps">in einen anderen</span> <span class="hps">iframe</span> <span class="hps">auf der Seite</span><span>.</span> <span class="hps">Siehe</span> <span class="hps">Arbeiten mit</span> <span class="hps">eingebetteten Frames anzeigen</span><span>.</span><br>
<span class="hps">Bitte beachten Sie die</span> <span class="hps">Konsole</span> <span class="hps">API</span> <span class="hps">für weitere Informationen über</span> <span class="hps">die Anmeldung</span> <span class="hps">von</span> <span class="hps">Inhalten</span><span>.</span><br>
<br>
<span class="hps">Beispiele</span><br>
<span class="hps">Beispiel:</span> <span class="hps">Eine Sicht auf</span> <span class="hps">den Inhalt einer</span> <span class="hps">DOM-Knoten</span><br>
<br>
<span class="hps">Angenommen, Sie haben</span> <span class="hps">einen</span> <span class="hps">DOM-Knoten</span> <span class="atn hps">mit der ID "</span><span>Titel"</span> <span class="hps">zu haben.</span> <span class="hps">In der Tat,</span> <span class="hps">diese</span> <span class="hps">Seite, die Sie</span> <span class="hps">gerade lesen</span> <span class="hps">muss man</span><span>,</span> <span class="hps">so können Sie</span> <span class="hps">öffnen Sie die</span> <span class="hps">Web-Konsole</span> <span class="hps">und</span> <span class="hps">versuchen Sie diese</span> <span class="hps">jetzt.</span><br>
<br>
<span class="hps">Werfen wir einen</span> <span class="hps">Blick auf den Inhalt</span> <span class="hps">dieses Knotens</span> <span class="hps">mit der</span> <span class="hps">$ ()</span> <span class="hps">und prüfen</span> <span class="hps">()</span> <span class="hps">Funktionen:</span></span></p>
<pre class="language-html"><code class="language-html">inspect($("#Titel"))</code></pre>
<p><br>
<br>
<span id="result_box" lang="de"><span class="hps">Es öffnet sich</span> <span class="hps">automatisch das</span> <span class="hps">Objekt-Inspektor</span> <span class="hps">und zeigt Ihnen</span> <span class="hps">den Inhalt des</span> <span class="hps">DOM-Knoten</span><span>, der die</span> <span class="hps">CSS-Selektor</span> <span class="atn hps">"</span><span>#title</span><span>"</span><span>, was natürlich</span> <span class="hps">ist das Element</span> <span class="atn hps">mit der ID "</span><span>Titel"</span> <span class="hps">entspricht.</span><br>
<span class="hps">Beispiel</span><span>: Dumping</span> <span class="hps">den Inhalt eines</span> <span class="hps">DOM-Knoten</span><br>
<br>
<span class="hps">Das ist</span> <span class="hps">schön und gut,</span> <span class="hps">wenn Sie geschehen,</span> <span class="hps">im</span> <span class="hps">Browser</span> <span class="hps">zu sitzen</span> <span class="hps">ein Problem</span> <span class="hps">aufweisen</span><span>, aber</span> <span class="hps">lassen Sie uns sagen</span> <span class="hps">Sie</span> <span class="hps">remote</span> <span class="hps">Debugging</span> <span class="hps">für einen Benutzer</span><span>,</span> <span class="hps">und</span> <span class="hps">müssen</span> <span class="hps">Sie einen Blick auf</span> <span class="hps">den Inhalt</span> <span class="hps">eines Knotens</span><span>.</span> <span class="hps">Sie können Ihre</span> <span class="hps">Benutzer</span> <span class="hps">öffnen Sie die</span> <span class="hps">Web-Konsole</span> <span class="hps">und Dump</span> <span class="hps">den Inhalt der</span> <span class="hps">Knoten</span> <span class="hps">in das Protokoll</span><span>, dann kopieren</span> <span class="hps">und fügen Sie ihn</span> <span class="hps">in eine</span> <span class="hps">E-Mail an</span> <span class="hps">Sie</span><span>,</span> <span class="hps">mit Hilfe der</span> <span class="hps">pprint</span> <span class="hps">() -Funktion</span><span>:</span></span><br>
</p>
<pre class="language-html"><code class="language-html">pprint($("#Titel"))</code></pre>
<p> </p>
<p>This spews out the contents of the node so you can take a look. Of course, this may be more useful with other objects than a DOM node, but you get the idea.</p>
|