((WebBrowser1.Document as IHTMLDocument3).getElementsByName('input_authnum').item(0,'') as IHTMLControlElement).focus; if WebBrowser1.Document <> nil then IHTMLWindow2(IHTMLDocument2(WebBrowser1.Document).ParentWindow).focus 剛找到了更簡(jiǎn)單的方法,也許是最簡(jiǎn)單的: if WebBrowser1.Document <> nil then IHTMLWindow4(WebBrowser1.Document).focus 還有,需要判斷文檔是否獲得焦點(diǎn)這樣來做: if IHTMLWindow4(WebBrowser1.Document).hasfocus then
|