2011-02-12 30 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

相關問題