Einzelnen Beitrag anzeigen

qicki

Registriert seit: 5. Jul 2004
22 Beiträge
 
Delphi 6 Personal
 
#2

Re: javaScript add to webbrowser

  Alt 29. Sep 2005, 15:38
ok habs jetzt doch selber herausgefunden


Delphi-Quellcode:
procedure AppendToWBA(document: IHTMLDocument2);
var
  novoScript : IHTMLDOMNode;
begin
  if Assigned(document) then
  begin
     novoScript := document.createElement('script') as IHTMLDOMNode;
    (novoScript as IHTMLScriptElement).text := 'function setTimeout(){};function window.focus(){};function focus(){};function window.alert(){};function alert(){}; function window.confirm(){};function confirm(){}; function window.prompt(){};function prompt(){};function window.open(){};';
    (document.body as IHTMLDOMNode).appendChild(novoScript);
  end;
end;

procedure TForm1.WBLoad(ASender: TObject; const pDisp: IDispatch;var URL: OleVariant);
var
  currentBrowser: IWebBrowser2;
  document: IHTMLDocument2;
begin
  currentBrowser := pDisp as IWebBrowser2;
  document := currentBrowser.Document as IHTMLDocument2;
  AppendToWBA(document);
end;
manchmal ich weniger halt doch mehr
  Mit Zitat antworten Zitat