- XML DOM 基礎
- XML DOM - 首頁
- XML DOM - 概述
- XML DOM - 模型
- XML DOM - 節點
- XML DOM - 節點樹
- XML DOM - 方法
- XML DOM - 載入
- XML DOM - 遍歷
- XML DOM - 導航
- XML DOM - 訪問
- XML DOM 操作
- XML DOM - 獲取節點
- XML DOM - 設定節點
- XML DOM - 建立節點
- XML DOM - 新增節點
- XML DOM - 替換節點
- XML DOM - 移除節點
- XML DOM - 克隆節點
- XML DOM 物件
- DOM - 節點物件
- DOM - 節點列表物件
- DOM - 命名節點對映物件
- DOM - DOMImplementation
- DOM - 文件型別物件
- DOM - ProcessingInstruction
- DOM - 實體物件
- DOM - 實體引用物件
- DOM - 符號物件
- DOM - 元素物件
- DOM - 屬性物件
- DOM - CDATASection 物件
- DOM - 註釋物件
- DOM - XMLHttpRequest 物件
- DOM - DOMException 物件
- XML DOM 實用資源
- XML DOM - 快速指南
- XML DOM - 實用資源
- XML DOM - 討論
DOM - ProcessingInstruction 物件屬性 - target
屬性 target 標識指令或資料目標應用程式。
語法
以下是 target 屬性用法的語法。
ProcessingInstruction.target
| 序列號 | 引數和說明 |
|---|---|
| 1 | target 標識指令或資料目標應用程式。 |
示例
以下示例演示了 target 屬性的使用 -
<!DOCTYPE html>
<html>
<head>
<script>
// loads the xml string in a dom object
function loadXMLString(t) {
// for non IE browsers
if (window.DOMParser) {
// create an instance for xml dom object
parser = new DOMParser();
xmlDoc = parser.parseFromString(t,"text/xml");
} else // code for IE {
// create an instance for xml dom object
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
xmlDoc.loadXML(t);
}
return xmlDoc;
}
function get_firstChild(p) {
a = p.firstChild;
return a;
}
</script>
</head>
<body>
<script>
var xml = "<Employee>";
xml = xml+"<FirstName>";
xml = xml+"<?piTarget piData more piData?>";
xml = xml+"</FirstName>";
xml = xml+"</Employee>";
// calls the loadXMLString() with "text" function and store the xml dom in a variable
var xmlDoc = loadXMLString(xml);
var x = get_firstChild(xmlDoc.getElementsByTagName("FirstName")[0]);
document.write("First child is : ");
document.write(x.nodeName);
//the following should be "piData more piData"
alert(x.data);
//the following should be "piTarget"
alert(x.target);
</script>
</body>
</html>
執行
將此檔案以 dom_processinginstruction_target.htm 為名稱儲存到伺服器路徑。輸出如下所示 -
dom_processinginstruction_object.htm
廣告