1

如何使用 WebBrowser 在 html 页面中调用 textarea 控件的 onkeypress 事件?

4

1 回答 1

4

这是一种后期绑定的方式:

procedure TBrowserPageIE.Test;
var
  doc : OleVariant;
  el  : OleVariant;
  v   : OleVariant;
begin
  if FBrowser.Document <> nil then begin
    doc := FBrowser.Document;
    el := doc.getElementById('myTextArea');
    el.FireEvent('onkeypress', v);
  end;
end;

请为 nil/异常处理添加一些代码。

于 2011-05-24T18:05:24.013 回答