Adding local images to a remote page?


  • PeteSearch on Firefox adds a couple of icons next to every search result, to show a split-screen or text preview of the page. To add these icons to the page, I just use the chrome:// protocol to reference the icon pngs that are part of my extension on-disk inside an <img> tag.

    I tried doing something similar with my BHO, referencing the installed location of my BHO using the file:// protocol. This fails, I'm guessing due to cross-domain scripting security policies.

    If the data:// protocol was supported, I could supply the image data directly
    , but that's not an option on IE. At the moment, I'm referencing the images from my own server, but this is not ideal since it raises privacy concerns for users (eg is it phoning home?) and seems inefficient.

    Is there any way to create an image element from local data in a BHO? I was hoping for a IHTMLDocument3.createImageElement(dataInMemory) equivalent call, but I haven't been able to find anything. Any ideas?

    Thursday, June 21, 2007 12:55 AM

All replies

  • Hi Pete,

    Have you tried the res:\\ protocol? Add your images as a type 23 resource to your BHO dll/exe.



    Thursday, June 21, 2007 9:35 PM
  • Thanks Rob, that is a good idea, I hadn't seen that protocol. I'll try it and see if that works. This line in the res:// docs does make me wonder if the cross-domain security policy may interfere?
    Note  Internet Explorer 6 Service Pack 1 (SP1) no longer allows browsing a local machine from the Internet zone. For instance, if an Internet site contains a link to a local file, Internet Explorer 6 SP1 displays a blank page when a user clicks on the link. Previous versions of Internet Explorer followed the link to the local file.
    Friday, June 22, 2007 12:15 AM
  • However, this only works for non-SSL web sites.
    Friday, June 29, 2007 1:07 PM