PluginArray
已棄用:此特性不再推薦。雖然某些瀏覽器可能仍然支援它,但它可能已經從相關的網路標準中刪除,可能正在刪除過程中,或者可能僅為相容性目的而保留。請避免使用它,如果可能,請更新現有程式碼;請參閱本頁底部的相容性表格以指導您的決策。請注意,此特性可能隨時停止工作。
PluginArray 介面用於儲存 物件的列表;它由 Pluginnavigator.plugins 屬性返回。PluginArray 不是 JavaScript 陣列,但它具有 length 屬性,並支援使用方括號表示法 (plugins[2]) 以及 item(index) 和 namedItem("name") 方法來訪問單個元素。
注意: 在最新瀏覽器版本中,PluginArray 物件的自有屬性不再是可列舉的。
例項屬性
PluginArray.length只讀 已棄用-
陣列中外掛的數量。
例項方法
PluginArray.item已棄用-
返回陣列中指定索引處的
。Plugin PluginArray.namedItem已棄用-
返回指定名稱的
。Plugin PluginArray.refresh已棄用-
重新整理當前頁面上的所有外掛,可選地重新載入文件。
示例
以下示例函式返回 Shockwave Flash 外掛的版本。
js
const pluginsLength = navigator.plugins.length;
document.body.innerHTML =
`${pluginsLength} Plugin(s)<br>` +
`<table id="pluginTable"><thead>` +
`<tr><th>Name</th><th>Filename</th><th>description</th><th>version</th></tr>` +
`</thead><tbody></tbody></table>`;
const table = document.getElementById("pluginTable");
for (let i = 0; i < pluginsLength; i++) {
let newRow = table.insertRow();
newRow.insertCell().textContent = navigator.plugins[i].name;
newRow.insertCell().textContent = navigator.plugins[i].filename;
newRow.insertCell().textContent = navigator.plugins[i].description;
newRow.insertCell().textContent = navigator.plugins[i].version ?? "";
}
以下示例顯示已安裝外掛的資訊。
js
const pluginsLength = navigator.plugins.length;
document.write(
`${pluginsLength.toString()} Plugin(s)<br>` +
`Name | Filename | description<br>`,
);
for (let i = 0; i < pluginsLength; i++) {
document.write(
`${navigator.plugins[i].name} | ${navigator.plugins[i].filename} | ${navigator.plugins[i].description} | ${navigator.plugins[i].version}<br>`,
);
}
規範
| 規範 |
|---|
| HTML # pluginarray |
瀏覽器相容性
載入中…
除了將每個外掛作為零索引的數字屬性進行偽陣列列表顯示外,Firefox 還提供了直接在 PluginArray 物件上的外掛名稱屬性。