【发布时间】:2011-08-28 11:15:29
【问题描述】:
我们有一个用 C# 编写的浏览器帮助对象 (BHO),它在 IE8 中运行良好。但是,在 IE9 中访问命名空间中的标记和属性不再起作用。例如,与
<p xmlns:acme="http://www.acme.com/2007/acme">
<input type="text" id="input1" value="" acme:initial="initial"/>
</p>
以下在 IE8 中的工作:
IHTMLElement element = doc.getElementById("input1");
String initial = element.getAttribute("evsp:initial", 0) as String;
IE8 将“acme:initial”视为一个文本标记,而 IE9 尝试以“acme”作为命名空间前缀来更好地识别命名空间。
使用 getAttributeNS 似乎合适,但似乎不起作用:
IHTMLElement6 element6 = (IHTMLElement6)element;
String initial6 = (String)element6.getAttributeNS("http://www.acme.com/2007/acme",
"initial");
在上面,element6 设置为 mshtml.HTMLInputElementClass,但 initial6 为 null。
由于旧的文本标记和命名空间方法都不起作用,看起来我们陷入了困境。
如果包含具有命名空间前缀的属性,也可以遍历元素的实际属性。
有没有办法安装IE9来获取命名空间前缀属性的值?
一些细节: Microsoft.mshtml.dll 的默认 PIA 是版本 7。 IE9 使用 mshtml.dll 版本 9。 我们使用 c:\C:\Windows\System32\mshtml.tlb(随 IE9 安装)来生成缺少的接口,例如 IHTMLElement6,并将它们包含在我们的项目中。 我们过去曾成功地将这种技术用于其他 IE(N-1)、IE(N) 差异。
【问题讨论】:
标签: c# internet-explorer-9 bho mshtml