代码
{
WB_Set3DBorderStyle
}
procedure WB_Set3DBorderStyle(Sender: TWebBrowser; bValue: Boolean);
var
Document: IHTMLDocument2;
Element: IHTMLElement;
StrBorderStyle: string ;
begin
// 去掉边框
try
Document : = TWebBrowser(Sender).Document as IHTMLDocument2;
if Assigned(Document) then
begin
Element : = Document.Body;
if Element <> nil then
begin
case BValue of
False: StrBorderStyle : = ' none ' ;
True: StrBorderStyle : = '' ;
end ;
Element.Style.BorderStyle : = StrBorderStyle;
end ;
end ; // 去掉滚动条
Sender.OleObject.Document.Body.Scroll : = ' no ' ;
except
// ..
end ;
end ;
procedure WB_Set3DBorderStyle(Sender: TWebBrowser; bValue: Boolean);
var
Document: IHTMLDocument2;
Element: IHTMLElement;
StrBorderStyle: string ;
begin
// 去掉边框
try
Document : = TWebBrowser(Sender).Document as IHTMLDocument2;
if Assigned(Document) then
begin
Element : = Document.Body;
if Element <> nil then
begin
case BValue of
False: StrBorderStyle : = ' none ' ;
True: StrBorderStyle : = '' ;
end ;
Element.Style.BorderStyle : = StrBorderStyle;
end ;
end ; // 去掉滚动条
Sender.OleObject.Document.Body.Scroll : = ' no ' ;
except
// ..
end ;
end ;
这个函数只需要 TWebBrowser 装载完网页文件时,调用一下。
然后将html文件开头替换成
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
转载于:https://www.cnblogs.com/rogee/archive/2010/09/20/1832037.html