首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

请教在WebBrowser中如何保存div的图片呢

2013-01-04 
请问在WebBrowser中怎么保存div的图片呢?div styleheight:200pxbackground-image:url(1.jpg) iddi

请问在WebBrowser中怎么保存div的图片呢?
<div style="height:200px;background-image:url(1.jpg);" id="div1" />

 

我要保存div1的图片,怎么保存呢?我用下面的方法不能保存


procedure TForm1.Button7Click(Sender: TObject);
var       
d2,D:IHTMLDocument2; 
d1:IHTMLDocument;
e:IHTMLElement; 
e2:IHTMLElement2; 
cp:IHTMLControlRange;
img,img1:IHTMLImgElement; 
ce:IHTMLControlElement; 
myitem:Olevariant; 
i:integer;
rang:IHTMLControlRange;
doc: IHTMLDocument2;
mDiv: IHTMLElement;
begin
doc := WebBrowser1.Document as IHTMLDocument2;

mDiv := doc.all.item('div3',0) as IHTMLElement;

D:= webbrowser1.Document   as   IHTMLDocument2;
e:=d.body   as   IHTMLElement;
e2:=e   as   IHTMLElement2;
cp:=e2.createControlRange   as   IHTMLControlRange;
d2:=   webbrowser1.Document   as   IHTMLDocument2;
myitem   :=   WebBrowser1.Document;
ce:=mDiv   as   IHTMLControlElement;

cp.add(ce);
cp.execCommand('Copy',false,0);
try
Image1.Picture.Assign(ClipBoard);
except
end;
end;
[解决办法]
doc.all.item('div3',0),这个找的是 div3,你给的是div1,id="div1"
[解决办法]
直接得到图片的url或生成规则,自己idhttpclt去下载?

热点排行