[WebBrowser]一个大家都想明白的难题!!!在网上能用的一个网页的连接,把它下载到本机上就不能用了!!! ( 积分: 50 )

  • 主题发起人 主题发起人 iyesno
  • 开始时间 开始时间
I

iyesno

Unregistered / Unconfirmed
GUEST, unregistred user!
在网上地址是:http://okyesno.com/hh.htm
下载到本机上:file:///F:/hh.htm
我是用WebBrowser做了一个程序!!在不改网页的前提下通过设定WebBrowser能不能把
file:///F:/ 设成http://okyesno.com/ 呢?

以下是我写的程序!!!
地址成了:about:blank/hss.htm
我想通过设定WebBrowser把它改为http://okyesno.com/hss.htm
不是改<a href="/hss.htm" target="_blank">地址连接</a> '为:
<a href="http://okyesno.com/hss.htm" target="_blank">

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, SHDocVw;

type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure WebBrowser1DocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

uses MSHTML, Activex; ////////////////////////////这是一定要引用的!!!

procedure TForm1.Button1Click(Sender: TObject);
var
vv: Variant;
HTMLDocument: IHTMLDocument2;
Content: string;
begin



tag := 0;
WebBrowser1.Navigate('about:blank');
while(tag=0) do Application.ProcessMessages;
vv := VarArrayCreate([0, 0], varVariant);
Content := '<a href="/hss.htm" target="_blank">地址连接</a> ';
vv[0] :=Content;
HTMLDocument := WebBrowser1.Document as IHTMLDocument2;
HTMLDocument.Write(PSafeArray(TVarData(vv).VArray));
HTMLDocument.Close;
end;

procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
begin
tag := 1;
end;

end.
 
在网上地址是:http://okyesno.com/hh.htm
下载到本机上:file:///F:/hh.htm
我是用WebBrowser做了一个程序!!在不改网页的前提下通过设定WebBrowser能不能把
file:///F:/ 设成http://okyesno.com/ 呢?

以下是我写的程序!!!
地址成了:about:blank/hss.htm
我想通过设定WebBrowser把它改为http://okyesno.com/hss.htm
不是改<a href="/hss.htm" target="_blank">地址连接</a> '为:
<a href="http://okyesno.com/hss.htm" target="_blank">

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, SHDocVw;

type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure WebBrowser1DocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

uses MSHTML, Activex; ////////////////////////////这是一定要引用的!!!

procedure TForm1.Button1Click(Sender: TObject);
var
vv: Variant;
HTMLDocument: IHTMLDocument2;
Content: string;
begin



tag := 0;
WebBrowser1.Navigate('about:blank');
while(tag=0) do Application.ProcessMessages;
vv := VarArrayCreate([0, 0], varVariant);
Content := '<a href="/hss.htm" target="_blank">地址连接</a> ';
vv[0] :=Content;
HTMLDocument := WebBrowser1.Document as IHTMLDocument2;
HTMLDocument.Write(PSafeArray(TVarData(vv).VArray));
HTMLDocument.Close;
end;

procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
begin
tag := 1;
end;

end.
 
没人会啊
 
后退
顶部