<body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener('load', function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <div id="navbar-iframe-container"></div> <script type="text/javascript" src="https://apis.google.com/js/platform.js"></script> <script type="text/javascript"> gapi.load("gapi.iframes:gapi.iframes.style.bubble", function() { if (gapi.iframes && gapi.iframes.getContext) { gapi.iframes.getContext().openChild({ url: 'https://www.blogger.com/navbar.g?targetBlogID\x3d6016338663470588542\x26blogName\x3dA+Guide+to+Hell\x26publishMode\x3dPUBLISH_MODE_BLOGSPOT\x26navbarType\x3dBLUE\x26layoutType\x3dCLASSIC\x26searchRoot\x3dhttps://shasini.blogspot.com/search\x26blogLocale\x3den_US\x26v\x3d2\x26homepageUrl\x3dhttp://shasini.blogspot.com/\x26vt\x3d-3621103276626359617', where: document.getElementById("navbar-iframe-container"), id: "navbar-iframe" }); } }); </script>

About

"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt."

XMLHttpRequest image and display it in browser? Tuesday, April 17, 2007 |

The Data URL scheme (RFC at http://www.ietf.org/rfc/rfc2397.txt ) You can deliver the image as base64 encoded string with your XMLHTTP or payload. You’d do segregate textual data and image data part using XML of JSON. Then set the SRC attribute with your encoded data, here’s an example that works with Firefox.


<img src="data:image/gif;base64,R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAAw AAAC8IyPqcvt3wCcDkiLc7C0qwyGHhSWpjQu5yqmCYsapyuvUUlvONmOZtfzgFz ByTB10QgxOR0TqBQejhRNzOfkVJ+5YiUqrXF5Y5lKh/DeuNcP5yLWGsEbtLiOSp a/TPg7JpJHxyendzWTBfX0cxOnKPjgBzi4diinWGdkF8kjdfnycQZXZeYGejmJl ZeGl9i2icVqaNVailT6F5iJ90m6mvuTS4OK05M0vDk0Q4XUtwvKOzrcd3iq9uis F81M1OIcR7lEewwcLp7tuNNkM3uNna3F2JQFo97Vriy/Xl4/f1cf5VWzXyym7PH hhx4dbgYKAAA7" alt="Larry" />



Preview: only work in firefox
Larry

Labels: ,

Downloading Binary Streams with Javascript XMLHttpRequest |

This precious technique is researched & developed by Marcus Granado
Refer to http://mgran.blogspot.com/2006/08/downloading-binary-streams-with.html

Request binary stream in FF

load_url = function(url) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
var req = new XMLHttpRequest();
req.open('GET',url,false);
//XHR binary charset opt by Marcus Granado 2006 [http://mgran.blogspot.com]
req.overrideMimeType('text/plain; charset=x-user-defined');
req.send(null);
if (req.status != 200) return '';
return req.responseText;
}



Comments refer to working in IE

At 9/14/2006 9:50 AM , Ben said...
This sounds like a great way to fix this problem but unfortunately it doesn't seem to work in IE. I'm trying to preload images using this method but the Microsoft.XMLHTTP implementation of XmlHttpRequest unfortunately doesn't include overrideMimeType. I've tried to use req.setRequestHeader('Accept','text/plain; charset=x-user-defined') but this doesn't work either.

Any help would be greatly appreciated :)


At 9/14/2006 11:00 AM , Marcus Granado said...
Hi, Ben. I developed the technique above to work on Mozilla/Firefox, but I didn't test on IE or any other browser (BTW, IE understands x-user-defined charset). It would be interesting if you could sniff the http headers being sent by IE after using setRequestHeader() as you suggested, to see if the headers are really being modified and compare with the output of FF. You might also want to set the headers 'accept-charset' and 'content-type' to the charset/mimetype above and have a try.

Further, IE seems to be able to natively read binary raw bytes by reading the property 'XHR.responseStream', which FF lacks. Have e.g. a look here, here and
here.
Let me know if any of the above works.

Labels: ,