WebBrowser, IPersistStreamInit and javascript

For one of our desktop applications, we use an HTML interface loaded from local files into the WebBrowser control.

This works great, but now we want to download files from another source and try to transfer them using IPersistStreamInit (for example, this example on MSDN ). It seems to work fine except for links to javascript.js files (jQuery and others). He tries to download them from the "about:" location, which leads to errors.

I would really like to receive a callback event when the streams are transmitted through additional files, and substitute the necessary data. This may require too much, although suggestions for workarounds are welcome!

+4
source share
2 answers

Call CreateURLMoniker() to get the IMoniker interface, load your HTML data into it using the Load() method (which enters the IStream interface as input), and then you can use the IPersistMoniker browser IPersistMoniker instead of the IPersistStreamInit interface to process the data. The URL you pass to CreateURLMoniker() will be used as the base URL.

+3
source

You can use a lightweight custom protocol handler using the Asynchronous Pluggable Protocol , which will give a callback to files.

I have a demo code at http://www.jasontpenny.com/blog/2010/03/23/custom-protocol-handler-in-delphi/

+2
source

All Articles