Question Alter webbrowser src code before it's done loading?

J. Scott Elblein

Well-known member
Joined
Dec 14, 2006
Messages
166
Location
Chicago
Programming Experience
10+
Let's say there's an img src=blah on a web page that I am loading with a webbrowser control, and I want to alter it to say img src=blahblah instead ...

What I've been doing so far is waiting for the document to complete, doing a .replace, then saving the file to the hard drive, and finally navigating to that local altered version.

I was wondering if it's possible to skip the step of replacing and reloading the local page, and instead, just dynamically alter the original source code of the page AS it's loading the first time. Can this be done?
 
VB.NET:
Me.WebBrowser1.Document.Images(0).SetAttribute("src", "newimage.png")
 
How about if I need to replace a long string of text with another string? Like for example "/some/path/to/stuff.gif" with "http://www.somesite.com/some/path/to/stuff.gif" which can be found and replaced many times in the same file? (a mass replace of a local path with a full path)

Or just one string that isn't an attribute but is found in the source, like "Welcome to Florida" to "Sorry to see ya leave Florida"?
 
Back
Top