0
我想探索在JavaScript中clientCaps對象(我不是很熟悉MSIE行爲)。但沒有多少運氣。CLIENTCAPS探頭使用javascript
由於其他方面的限制,我真的不能修改網頁的HTML,因此試圖動態添加元素。我使用的代碼如下所示 - 我不斷收到異常(對象不支持此屬性或方法)。任何想法我做錯了什麼?
var out="";
try {
var b = document.getElementsByTagName("body")[0];
var s = document.createElement("div");
// attempt 1 - exception
// s.id="oClientCaps";
// s.style.behaviour="url('#default#clientCaps')";
//
// attempt 2 - exception
// s.innerHTML='<a ID="oClientCaps" style="behavior:url(#default#clientcaps)"></a>';
//
// attempt 3 - exception
s.id="oClientCaps";
s.addBehavior ("#default#clientCaps");
b.appendChild(s);
var clids = Array('{7790769C-0471-11D2-AF11-00C04FA35D02}', // address bk
...
'{08B0E5C0-4FCB-11CF-AAA5-00401C608500}'); // MS VM
for(i=0;i<clids.length;i++) {
if(oClientCaps.isComponentInstalled(clids[i],"ComponentID")){
out+=clsids[i]
+ oClientCaps.getComponentVersion(clids[i],"ComponentID")
+ '; ';
} else {
out+='N; '
}
}
} catch (e) {
out+="clientCaps failed";
}
return out;
TIA
也許是這樣的:'b.apendChild(S);' ? – Teemu 2012-04-23 09:47:39
@Teemu:看起來很棒 - 但是當我粘貼代碼時,這只是一個錯字 - 原文是OK! – symcbean 2012-04-23 11:46:20