Programming Delphi How to get the inner html source of a selected object in a TWebbrowser?
Notice: Undefined variable: relatedArticlesCount in /home/wwwroot/codeback.net/plugins/content/tags.php on line 149

Well, let us just to see the example. This example use a TButton and a TWebBrowser component in a form. Double click the button, add the following codes.

procedure TForm1.Button1Click(Sender: TObject);
strHtml String;
begin
  if Webbrowser1.OleObject.Document.Selection.type = 'Control' then
  begin
    strHtml = Webbrowser1.OleObject.Document.Selection.CreateRange.CommonParentElement.innerHtml;      ShowMessage('The selected object's inner html source is: ' + strHtml);
  end
  else
  begin
    strHtml = Webbrowser1.OleObject.Document.Selection.createRange.innerHtml;
    ShowMessage('The selected text's inner html source is: " + strHtml);
  end;
end;

Ok, run the program to check the result. Good luck!


Add comment


Security code
Refresh

Programming - Delphi