【发布时间】:2011-06-25 22:37:27
【问题描述】:
在"sign in" to login.live 或via msdn.com page 的过程中,DHTML 生成的表单似乎行为不端,因此找到第一个带有 tagName“输入”的IHTMLElement 元素并将其转换为IHTMLInputElement 字段可以看到它有type="text",但是在查询时无法提供IHTMLInputTextElement 接口。其他任何输入字段都没有为其特定类型提供接口。
相比之下,在点击http://gmail.com 时,相同的过程也可以正常工作。
我不知道这个错误的来源,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();
}
【问题讨论】:
标签: internet-explorer dhtml bho