Learner
Learner

Reputation: 2339

How to display embedded images in IE7?

I am trying to display embedded image in IE7. The image is encoded in base64 encoding.

"src="data:image/jpg;base64"

This is what I tried..

I dowloaded the encoder / decoder script from below link.

http://www.webtoolkit.info/javascript-base64.html

I tried to decode the image but I am getting invalid pointer error, not sure why. Can someone let me know a way to display embedded pictures in IE7?

I used this link: http://dean.edwards.name/weblog/2005/06/base64-ie/

var BASE64_DATA = /^data:.*;base64/i;
        function fixBase64(img) {
            if (BASE64_DATA.test(img.src)) {
                document.writeln(Base64.decode(img.src.slice(5))); // Just trying to display the picture in screen 
            }
        };

            for (var i = 0; i < document.images.length; i++) {
                fixBase64(document.images[i]);
            }

Thanks,
Barani

Upvotes: 0

Views: 826

Answers (1)

brothercake
brothercake

Reputation: 136

The invalid pointer error still occurs in older IE8 builds, but you can workaround it by referring to the SRC in the image attributes collection, i.e. instead of this:

img.src

use this:

img.attributes.src.value

Upvotes: 1

Related Questions