jodyglidden
asked on
Disable webbrowser control images
Hi,
I know that it's possible from C++ to use DLIMAGES to disable downloading images for an instance of the webbrowser control.
http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/hosting/wbcustomization.asp
I don't want to simply use the registry to turn off images for all IE instances.
Could somebody tell me how to disable for one instance of the webbrowser control in VB?
I know that it's possible from C++ to use DLIMAGES to disable downloading images for an instance of the webbrowser control.
http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/hosting/wbcustomization.asp
I don't want to simply use the registry to turn off images for all IE instances.
Could somebody tell me how to disable for one instance of the webbrowser control in VB?
ASKER
Hi,
Actually, you don't have to do this. There is a way that they can be disabled for just the webbrowser control instance using the
DLIMAGES flag. I've found several references to it here on this site however no explainations on how I can use vb yet. My application is in vb.
Actually, you don't have to do this. There is a way that they can be disabled for just the webbrowser control instance using the
DLIMAGES flag. I've found several references to it here on this site however no explainations on how I can use vb yet. My application is in vb.
ASKER
This is quite close I think but it doesn't do it. I believe it is implementing some of the customized flags for vb webbrowser control but not the one that I need (not downloading images). It could be that it's for IE 4 perhaps rather than IE 5. Anyone able to customize this to make it work maybe?
Sorry, just noticed that my link was the same as bingie.
Have found a possible solution in a chinese page:
http://hpcgi1.nifty.com/MADIA/VBBBS2/wwwlng.cgi?print+200406/04060091.txt
Please read carefully.
What you need is an Interface to the WebBrowser control to pass the attribute. I think the code exposed do it right.
http://hpcgi1.nifty.com/MADIA/VBBBS2/wwwlng.cgi?print+200406/04060091.txt
Please read carefully.
What you need is an Interface to the WebBrowser control to pass the attribute. I think the code exposed do it right.
ASKER
This may be it but I can't seem to get the code working. I can't find any way to reference IOleControl. Anyone who can turn this into working code?
ASKER
Well I found a control and some type libraries that someone made up to try to take advantage of this but I can't seem to get them working. Anyone able to?
https://www.experts-exchange.com/questions/21161889/Webbrowser-control-with-no-images.html
https://www.experts-exchange.com/questions/21161889/Webbrowser-control-with-no-images.html
*jumps in from your other question*
The below may not be a very efficient method of blocking images, but from testing, they don't seem to download. I just removed the SRC of the IMG elements so the "empty space" will still appear. You may want to keep it that way so to not disrupt the layout of pages.
Form1:
--------------------
'Include a reference to: Microsoft HTML Object Library
Option Explicit
Private blnDisableImages As Boolean
Private Sub Form_Load()
blnDisableImages = False
Call WebBrowser1.Navigate("http://www.yahoo.com")
End Sub
Private Sub Timer1_Timer()
Dim objDoc As HTMLDocument
Dim objCol As IHTMLElementCollection
Dim objImg As HTMLImg
Set objDoc = WebBrowser1.Document
If Not (objDoc Is Nothing) Then
Set objCol = objDoc.All.tags("IMG")
For Each objImg In objCol
objImg.src = vbNullString
Next objImg
End If
If WebBrowser1.ReadyState = READYSTATE_COMPLETE Then
Timer1.Enabled = False
End If
End Sub
Private Sub WebBrowser1_DownloadComple te()
If blnDisableImages = True Then
Timer1.Interval = 10
Timer1.Enabled = True
End If
End Sub
The below may not be a very efficient method of blocking images, but from testing, they don't seem to download. I just removed the SRC of the IMG elements so the "empty space" will still appear. You may want to keep it that way so to not disrupt the layout of pages.
Form1:
--------------------
'Include a reference to: Microsoft HTML Object Library
Option Explicit
Private blnDisableImages As Boolean
Private Sub Form_Load()
blnDisableImages = False
Call WebBrowser1.Navigate("http://www.yahoo.com")
End Sub
Private Sub Timer1_Timer()
Dim objDoc As HTMLDocument
Dim objCol As IHTMLElementCollection
Dim objImg As HTMLImg
Set objDoc = WebBrowser1.Document
If Not (objDoc Is Nothing) Then
Set objCol = objDoc.All.tags("IMG")
For Each objImg In objCol
objImg.src = vbNullString
Next objImg
End If
If WebBrowser1.ReadyState = READYSTATE_COMPLETE Then
Timer1.Enabled = False
End If
End Sub
Private Sub WebBrowser1_DownloadComple
If blnDisableImages = True Then
Timer1.Interval = 10
Timer1.Enabled = True
End If
End Sub
ASKER
I think this would remove the img tags but I don't think it would stop them from downloading. I might be mistaken but I don't see anything here that would turn them off.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I think you're right. This should do it in most cases. Thanks very much.
ASKER
If I try going to a site that I've never gone to I still have the images flash then disappear so they must be still downloading.
If they are loading then they should be cached in Temporary Internet Files. If they are there, then they are being downloaded.
ASKER
These are sites that I'm going to for the first time. I'm just making up site names like www.abc.com for example and the images still show up for a split second. I would have thought also, that zzzzzooc's approach might work since maybe download complete would be fired when the first html is downloaded however that must not be the case or the images wouldn't flash for sites that we've never been to.
I've tried it and the only images that download are for those that don't belong to <img> elements (such as backgrounds, etc.). The only time the images display then disappear (from testing) is from them being cached but if they aren't, they won't display. It's not a very elegant approach so there may be issues with slower computers or possibly different versions of IE being used.
http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q183/2/35.ASP&NoWebContent=1
You might have to disable them in IE, then enable them when finished.