Trying to Display Image in an iFrame

  • Thread starter Thread starter Abhishek Srivastava
  • Start date Start date
A

Abhishek Srivastava

Hello All,

I am trying to obtain an image asynchronously for this I have written code
which uses XMLHTTP object to retreive the image.

now I have to display this image in an iframe. when I say

iframe.contentWindow.document.write(xmlHttp.responseText);

I get an text as "JFIF" in my frame.

Why am I not able to see the image ?

I cannot do something like <img src="img.aspx" /> because I want to fetch
the image asynchronously. using the img tag would mean that I fetch the
image in the same thread as the main page.

regards,
Abhishek.
 
Hello All,
I am trying to obtain an image asynchronously for this I have written code
which uses XMLHTTP object to retreive the image.

now I have to display this image in an iframe. when I say

iframe.contentWindow.document.write(xmlHttp.responseText);

I get an text as "JFIF" in my frame.

Why am I not able to see the image ?

I cannot do something like <img src="img.aspx" /> because I want to fetch the
image asynchronously. using the img tag would mean that I fetch the image in
the same thread as the main page.

regards,
Abhishek.

Are you sure? IIRC first the browser needs to decode the html to find
the <img> tag. The browser will then issue a seperate request to fetch
that image.
And an image is not "text", so that may be why "responseText" gives
wrong results.

Hans Kesting
 
The browser will then issue a seperate request to fetch that image.

It is a separate request. But it is on the same thread. In my application,
first the browser submits the request for form processing when that
completes, it is downloading the image.
And an image is not "text", so that may be why "responseText" gives

So how can I extract the binary data out of HTTPRequest. Sorry but I am not
very well versed with JavaScript programming.

regards,
Abhishek.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

IFrame Image resizing 1
broken image problem 1
Add iFrames dynamically 2
Protect an Image File in ASP.NET Web Project? 7
Imaging 2
problem: image not found, 2
SWF Player IFrame PHP 0
Load Pdf files in Iframe 2

Back
Top