2011-02-12 33 views
0

在的"sign in" to login.livevia msdn.com page的DHTML生成形式的过程似乎是错误操作,使得在找到一个第一IHTMLElement元件用的tagName“输入”和转换,要一个IHTMLInputElement字段可以看到它具有类型=“文本”,然而,它在查询时未能提供IHTMLInputTextElement界面。其他任何输入字段都不为其特定类型提供接口。InternetExplorer在BHO中输入标签类型文本不转换为IHTMLInputTextElement?

相比之下,当击中​​时,同样的过程也很好。

我对这个错误的来源感到茫然,DHTML,login.live,月亮在错误的阶段? 在IE7和IE8上获取相同的问题,因此似乎不是特定于版本的。 无论IE兼容模式如何,都会遇到同样的问题。

下面是一个简单的例子

TSharedField Factory(CComPtr<IHTMLElement>& _Element) 
{ 
CComQIPtr<IHTMLTextAreaElement> TextAreaField = _Element; 
if (TextAreaField) 
    return TSharedField(new Text(TextAreaField)); 

CComQIPtr<IHTMLInputTextElement> TextField = _Element; 
if (TextField) 
    return TSharedField(new Text(TextField)); 

CComQIPtr<IHTMLInputButtonElement> ButtonField = _Element; 
if (ButtonField) 
    return TSharedField(new Button(ButtonField)); 

CComQIPtr<IHTMLInputFileElement> FileField = _Element; 
if (FileField) 
    return TSharedField(new CWebField_File(FileField)); 

CComQIPtr<IHTMLInputHiddenElement> HiddenField = _Element; 
if (HiddenField) 
    return TSharedField(new Hidden(HiddenField)); 

CComQIPtr<IHTMLOptionButtonElement> BooleanField = _Element; 
if (BooleanField) 
    return TSharedField(new Boolean(BooleanField)); 

CComQIPtr<IHTMLSelectElement> SelectionField = _Element; 
if (SelectionField) 
    return TSharedField(new Select(SelectionField)); 

CComQIPtr<IHTMLInputImage> ImageField = _Element; 
if (ImageField) 
    return TSharedField(new Image(ImageField)); 

// Added for debug, only gets hit on login.live 
std::wstring type; 
HRESULT hr; 
DOM_SIMPLE_GET_STRING(type, _Element, get_tagName, hr); 

::OutputDebugString(type.c_str()); 
if(type == L"INPUT"){ 
    CComQIPtr<IHTMLInputElement> Input = _Element; 
    if(Input){ 
     DOM_SIMPLE_GET_STRING(type, Input, get_type, hr); 
     ::OutputDebugString((type+L"\n").c_str()); 
    } 
} 
    return TSharedField(); 
} 

回答

1

嗨格雷格,我在使用输入元素的BHO上工作,所以您的问题让我感兴趣。经过一些广泛的测试后,我和你一样撞到了同一面墙。在DocumentComplete事件触发后,您尝试为其IHTMLInputTextElement接口的名称和密码元素QI失败。但是,我发现您可以使用HTMLInputTextElementEvents接口成功吸收它们,这导致我得出结论:此问题的原因是MSHTML中的一个错误的结果。放心吧,月球的相位是A-OK。现在,让IE团队看看这个的机会有多大?

+0

看起来更专业的接口只是没有创建,所以我已经使用IHTMLInputElement和检查get_type值。因为我需要支持IE6-IE9,我猜这是最好的解决办法,直到它被修复。 – 2011-03-19 02:13:48

1

也许,这种类型=文本输入元件不完全初始化(未准备好)。

你检查了文档的readystate吗?

如果您从BHO启动了DHTML文档修改操作,则可能会发生此类问题。

安全和简单的替代方法是使用window.execScript函数来执行操作。

+0

感谢您的建议。检查并延迟,直到文件注册准备就绪,没有解决问题。作为window.execScript运行并不能解决问题。 – 2011-02-14 19:56:00

相关问题