Rectangle 27 0

delphi twebbrowser modify html before loaded?


For now the problem are solved by adding another twebbrowser to the project. (On a new tab). This webbrowser handle the login and keep the required php session alive. (It is automatic keept alive as long as the window stay open). Now Im able to load my own modifyed code without access denied.

Thanks for all your help.

Note
Rectangle 27 0

delphi twebbrowser modify html before loaded?


In VCL, yes. You can download the HTML yourself and modify it as needed (you need to insert a <base href> tag specifying the original URL into the <head> if the HTML contains relative links). Then navigate the browser to about:blank, query its Document for the IPersistStreamInit interface, and call its load() method, passing it the modified HTML using the VCL's TStringStream and TStreamAdapter classes.

Note
Rectangle 27 0

delphi twebbrowser modify html before loaded?


src="/java.js"
src="http://mysite/java.js"

Here is the approach:

  • Create a pluggable MIME filter (refer to IInternetProtocol) to monitor HTML document (mime type text/html) before it is rendered by TWebBrowser.

Here is a code example. And I highly suggest you read these documents first.

I removed the previous answer of using IDocHostUIHandler.TranslateURL, because I think it might mislead other readers, if they are in a similar situation.

Note