Export (0) Print
Expand All

target property

Gets the target of a processing instruction.

Document Object Model (DOM) Level 2 Core Specification, Section 1.3Internet Explorer 9

 

Syntax

JavaScript

p = object.target

 

Property values

Type: String

The name of the processing instruction.

Standards information

Remarks

Processing instructions are supported only by XML documents.

A processing instruction provides direction to an XML parser. The following code example shows a processing instruction that is specified in markup.


<?xml-stylesheet type="text/css" href="style.css"?>

For this example, the target property would return xml-stylesheet.

Examples

The following code example shows the relationship between the target and data properties of a processing instruction object.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
  "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <title>IE9 DOMProcessingInstruction Sample</title>
  <meta name="x-ua-compatible" content="ie=9">
  <script type="text/javascript">
  function showInfo() {
    try {
      var oImp = document.implementation;
      var oDoc = oImp.createDocument( "", "", null );  // works
      var sTarget = "xml-stylesheet";
      var sData = "type='text/css' href='style.css'";
      var oPI = oDoc.createProcessingInstruction( sTarget, sData );
      alert( oPI );
    } catch( oErr ) {
        var sError = "Error " + oErr.code + ": " + oErr.message;
        alert( sError );
    };
  }
  </script>
  </head>
  <body>
  <button onclick="showInfo();">Click Me!</button>
  </body>
</html>

See also

ProcessingInstruction
Reference
createProcessingInstruction
data

 

 

Show:
© 2014 Microsoft