delphi 将 HTML 代码直接加入到 TWebbrowser 组件中去


本文整理自网络,侵删。

 
将 HTML 代码直接加入到 TWebbrowser 组件中去
uses
  ActiveX;
procedure  WB_LoadHTML(WebBrowser:  TWebBrowser;  HTMLCode:  string);
var
  sl:  TStringList;
  ms:  TMemoryStream;
begin
  WebBrowser.Navigate('about:blank');
  if  Assigned(WebBrowser.Document)  then
  begin
      sl  :=  TStringList.Create;
      try
          ms  :=  TMemoryStream.Create;
          try
              sl.Text  :=  HTMLCode;
              sl.SaveToStream(ms);  0D
              ms.Seek(0,  0);
              (WebBrowser.Document  as  IPersistStreamInit).Load
(TStreamAdapter.Create(ms));
0A            finally
              ms.Free;
          end;
      finally
          sl.Free;
      end;
  end;
end;
procedure  TForm1.Button1Click(Sender:  TObject);
begin
  WB_LoadHTML(WebBrowser1,'  <html  >  <body    bgcolor=  "#0099FF  "  
>SwissDelphiCenter  </html  >');
end;

来源:http://iytnm.icoc.me/h-nd-1113.html#_np=125_826

相关阅读 >>

Delphi 取最前窗口标题(不重复)

Delphi 学习使用资源文件 - 字符串资源

Delphi webbrowser 加载html 将html代码转换成网页

Delphi dll注入x86/x64/win2k~win8.1全可用

Delphi xe2获取文件的 md5、crc、sha-1、sha-256、sha-512

Delphi ile dataset to xml

Delphi 让scrollbox响应鼠标的滚动消息

Delphi 动态更改webbrowser数据流内容

Delphi 用idhttp获取utf-8编码的网页

Delphi 获取星期的函数

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...