ProcessingInstruction: target Eigenschaft

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

Die schreibgeschützte target-Eigenschaft der ProcessingInstruction-Schnittstelle repräsentiert die Anwendung, auf die die ProcessingInstruction abzielt.

Zum Beispiel:

html
<?xml version="1.0"?>

ist eine Verarbeitungsvorschrift, deren target xml ist.

Wert

Ein String, der den Namen der Anwendung enthält.

Beispiel

In einem XML-Dokument

js
let parser = new DOMParser();
const doc = parser.parseFromString(
  '<?xml version="1.0"?><test/>',
  "application/xml",
);
const pi = doc.createProcessingInstruction(
  "xml-stylesheet",
  'href="mycss.css" type="text/css"',
);
doc.insertBefore(pi, doc.firstChild);

const output = document.querySelector("output");
output.textContent = `This processing instruction's target is: ${doc.firstChild.target}`;

In einem HTML-Dokument

Die Verarbeitungsvorschriftzeile wird als Comment-Objekt betrachtet und dargestellt.

html
<?xml version="1.0"?>
<pre></pre>
js
const node = document.querySelector("pre").previousSibling.previousSibling;
const result = `Node with the processing instruction: ${node.nodeName}: ${node.nodeValue}\n`;
document.querySelector("pre").textContent = result;

Spezifikationen

Specification
DOM
# dom-processinginstruction-target

Browser-Kompatibilität

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
target

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

Siehe auch