Delphi WebBrowser载入自定义HTML内容并显示


本文整理自网络,侵删。

 

use  
  Winapi.ActiveX;   //调用IPersistStreamInit类
 
procedure TForm1.Button2Click(Sender: TObject);  
var  
  PostList: TStringList;  
  Response, StrStream: TStringStream;  
  ResultString: string;  
begin  
  // 注册  
  PostList := TStringList.Create;  
  Response := TStringStream.Create('', TEncoding.UTF8);  
  try  
    IdHTTP1.HandleRedirects := True;  
  
    PostList.Add('forward=');  
    PostList.Add('jumpurl=http://www.hualongxiang.com/index.php');  
    PostList.Add('step=2');  
    PostList.Add('pwuser=' + Trim(Edit1.Text));  
    PostList.Add('lgt=0');  
    PostList.Add('pwpwd=' + Trim(Edit2.Text));  
    PostList.Add('cktime=31536000');  
  
    ResultString := IdHTTP1.Post('http://jia.hualongxiang.com/register.php', PostList);  
  
    if Pos('200 OK', IdHTTP1.ResponseText) > 0 then  
    begin  
      Memo1.Lines.Add(ResultString);  
   // 以下代码为WebBrowser显示自定义HTML内容  
        WebBrowser1.Navigate('about:blank'); // 必要  
        StrStream := TStringStream.Create(ResultString);  
        try  
          StrStream.Position:=0;  
          (WebBrowser1.Document as IPersistStreamInit).Load(TStreamadapter.Create(StrStream)); // 关键语句  
        finally  
          StrStream.Free;  
        end;  
    // 至此结束  
    end;  
  
  finally  
    PostList.Free;  
    Response.Free;  
  end;  
end;

https://blog.csdn.net/rshhs/article/details/8905859

相关阅读 >>

Delphi 提权,杀进程,删服务

Delphi在字符串中删除指定字符串

Delphi 下载一个jpg图片保存为bmp图片

Delphi数值转ip

Delphi xe andriod 文件后缀对应mime类型

Delphi idhttpserver接收http get请求解码问题

Delphi 在单独线程中运行窗体

Delphi unigrid记录check遍历

Delphi 计算农历的单元

Delphi xe安装2010版控件

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



打赏

取消

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

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

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

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

评论

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