Manually Writing the HTML in TWebBrowser Pt. 2
Posted
by nomad311
on Stack Overflow
See other posts from Stack Overflow
or by nomad311
Published on 2010-05-27T20:29:45Z
Indexed on
2010/05/27
20:31 UTC
Read the original article
Hit count: 401
delphi
As the name suggests this is a continuation (sort of) of http://stackoverflow.com/questions/2784679/manually-writing-the-html-in-twebbrowser
This time around I'm trying to add some auto-refresh logic to the HTML I get. I have pieced together an approach from several sources (see below). In short, I am trying to locate the title node and add a meta node after it (in the HTML head node). But, I get an access violation.
Here is the source:
iHtmlDoc := IHTMLDocument3(WebBrowser1.Document);
iHtmlEleTitle := IHTMLElement2(iHtmlDoc.getElementsByName('title').item(0, 0));
iHtmlEle := IHTMLElement2(IHTMLDocument2(iHtmlDoc).createElement(Format('<meta http-equiv="refresh" content="%d">', [1])));
iHtmlEleTitle.insertAdjacentElement('afterEnd', IHTMLElement(iHtmlEle));
And A (technically not functionally) different way of doing it ...casting is slightly different here:
IHTMLElement2(IHtmlDocument3(WebBrowser1.Document).getElementsByName('title').item(0, 0)).insertAdjacentElement('afterEnd', IHTMLDocument2(WebBrowser1.Document).createElement(Format('<meta http-equiv="refresh" content="%d">', [VPI_ISSUANCE_AUTO_RELOAD])));
Again all I get from Delphi is a access exception, and I fished through MSDN documentation on it, but now I'm hoping someone out there has gone through the same and has some insight. Any help?
Sources (I think this is all of them):
http://webdesign.about.com/od/metataglibraries/a/aa080300a.htm (auto-reload)
http://delphi.about.com/od/adptips2005/qt/webbrowserhtml.htm (web browser document as an HTML document)
http://msdn.microsoft.com/en-us/library/system.windows.forms.htmlelement.insertadjacentelement(VS.80).aspx (GetElementsByName)
http://www.experts-exchange.com/Web_Development/Components/ActiveX/Q_26131034.html (insertAdjacentElement)
http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_23407977.html (GetElementsByName)
© Stack Overflow or respective owner