Replacing iFrames crashed Add-In express for IE

Add-in Express™ Support Service
That's what is more important than anything else

Replacing iFrames crashed Add-In express for IE
 
Kenneth Nilsen




Posts: 2
Joined: 2011-07-20
Hi,
I am trying to write a toolbar for IE which will allow user to filter out certain elements (could be ads or similar things).

Now, I have two problems when I try to do this. The first is just a simple test I made to see if I could replace all iframe elements in a page. The test code is as follow:

            ...
            Dim doc As mshtml.HTMLDocument = Me.HTMLDocument
            If doc.body IsNot Nothing Then

                Dim iFrames As mshtml.IHTMLElementCollection = doc.getElementsByTagName("iframe")
                Dim iFrame As mshtml.IHTMLIFrameElement = Nothing

                For Each iFrame In iFrames
                    'iFrame.src = "http://startpage.com/"
                Next

            End If
            ...


If I uncomment 'iFrame.scr = ... IE will crash (IE9) OR (depending on which site I visit) the Add-In will crash. How can do this? I am doing it currently in a DownloadComplete event.

Second: I tried to replace all images in a page (with the same test loop as above). But the problem here is that IE loads all the original images BEFORE they are replaced with my hardcoded image link.

How can I make sure that I am able to replace all images (or other elements such as iframes) before the original content is presented to the user (to avoid the original ones to be loaded). This is obviously essentially quite important for my task as I want to protect the elements from being loaded at all (or there will be no point in my add-on...). I tried both DownloadComplete and DocumentComplete events with the same result.

Please assist.
Posted 20 Jul, 2011 14:03:48 Top
Kenneth Nilsen




Posts: 2
Joined: 2011-07-20
Sorry, I tried the Iframe replacement code with a DocumentComplete event right after writing the post above, and it seem to work (I guess I ignored trying with this event due to the image-test loaded the images in both events).

But I would appreciate any suggestions to my question with f.ex. original images being loaded before I can replace them. I want to parse and filter the raw HTML before the in-links (images, scripts, css etc.) are loaded so that I can manipulate the links or remove certain elements before the in-links are loaded.

Thanks!
Posted 20 Jul, 2011 14:11:12 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Kenneth,

It is not possible to replace original images before they are loaded. More over, custom 'src' of images should be an url and not the local path.
Posted 21 Jul, 2011 11:42:05 Top