R
renyp
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.Button1Click(Sender: TObject);
begin
form2:=tform2.Create(self);
form2.Webbrowser1.Navigate(GetCurrentDir+'/Templates.html');
form2.Show;
(form2.WebBrowser1.Document as IHTMLDocument2).body.insertAdjacentHTML('beforeEnd','<div class="STYLE2">'+'任我飞扬'+' '+'10:00:00'+'</div>');
(form2.WebBrowser1.Document as IHTMLDocument2).body.insertAdjacentHTML('beforeEnd','<div>&nbsp;&nbsp;&nbsp;&nbsp;'+'你好'+'</div>');
end;
执行到
(form2.WebBrowser1.Document as IHTMLDocument2).body.insertAdjacentHTML('beforeEnd','<div class="STYLE2">'+'任我飞扬'+' '+'10:00:00'+'</div>');
就会报错,若是这样
procedure TForm1.Button1Click(Sender: TObject);
begin
form2:=tform2.Create(self);
form2.Webbrowser1.Navigate(GetCurrentDir+'/Templates.html');
form2.Show;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
(form2.WebBrowser1.Document as IHTMLDocument2).body.insertAdjacentHTML('beforeEnd','<div class="STYLE2">'+'任我飞扬'+' '+'10:00:00'+'</div>');
(form2.WebBrowser1.Document as IHTMLDocument2).body.insertAdjacentHTML('beforeEnd','<div>&nbsp;&nbsp;&nbsp;&nbsp;'+'你好'+'</div>');
end;
分开则可以正确执行,请问为什么?
begin
form2:=tform2.Create(self);
form2.Webbrowser1.Navigate(GetCurrentDir+'/Templates.html');
form2.Show;
(form2.WebBrowser1.Document as IHTMLDocument2).body.insertAdjacentHTML('beforeEnd','<div class="STYLE2">'+'任我飞扬'+' '+'10:00:00'+'</div>');
(form2.WebBrowser1.Document as IHTMLDocument2).body.insertAdjacentHTML('beforeEnd','<div>&nbsp;&nbsp;&nbsp;&nbsp;'+'你好'+'</div>');
end;
执行到
(form2.WebBrowser1.Document as IHTMLDocument2).body.insertAdjacentHTML('beforeEnd','<div class="STYLE2">'+'任我飞扬'+' '+'10:00:00'+'</div>');
就会报错,若是这样
procedure TForm1.Button1Click(Sender: TObject);
begin
form2:=tform2.Create(self);
form2.Webbrowser1.Navigate(GetCurrentDir+'/Templates.html');
form2.Show;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
(form2.WebBrowser1.Document as IHTMLDocument2).body.insertAdjacentHTML('beforeEnd','<div class="STYLE2">'+'任我飞扬'+' '+'10:00:00'+'</div>');
(form2.WebBrowser1.Document as IHTMLDocument2).body.insertAdjacentHTML('beforeEnd','<div>&nbsp;&nbsp;&nbsp;&nbsp;'+'你好'+'</div>');
end;
分开则可以正确执行,请问为什么?