By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,164 Members | 850 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,164 IT Pros & Developers. It's quick & easy.

knowing the mime type of downloaded image

P: n/a
Hi,

When the browser downloaded an image that had the .php extension but
the header "Content-type: image/png", the browsers know how to display
it. Is there any way to use javascript in the page to find out what it
decided to do? Something like parent.myframe.mimeType?

Dan
Jan 28 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Dan Gelder wrote:
When the browser downloaded an image that had the .php extension but
the header "Content-type: image/png", the browsers know how to display
it. Is there any way to use javascript in the page to find out what it
decided to do? Something like parent.myframe.mimeType?
What would frames have to do with it? This is about an *image* resource.

Quick hack (without required feature tests):

var x = new XMLHttpRequest();
x.open("HEAD", "foo.php", false);
x.onreadystatechange = function()
{
if (x.readyState == 4 && /^0|2\d\d$/.test(x.status))
{
window.alert(x.getResponseHeader("Content-Type"));
}
};
x.send(null);

Search for "XHR" or "AJAX" for details.
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Jan 28 '08 #2

P: n/a
On Jan 28, 2:00 pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
Dan Gelder wrote:
When the browser downloaded an image that had the .php extension but
the header "Content-type: image/png", the browsers know how to display
it. Is there any way to use javascript in the page to find out what it
decided to do? Something like parent.myframe.mimeType?

What would frames have to do with it? This is about an *image* resource.

Quick hack (without required feature tests):

var x = new XMLHttpRequest();
x.open("HEAD", "foo.php", false);
x.onreadystatechange = function()
{
if (x.readyState == 4 && /^0|2\d\d$/.test(x.status))
{
window.alert(x.getResponseHeader("Content-Type"));
}
};
x.send(null);

Search for "XHR" or "AJAX" for details.

PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
The frame was sort of unclear to you, I had written a frameset that
would show a list of files in the left frame, and whatever file you
clicked on the right. If the file turned out to be a png I wanted to
draw it against a checkerboard pattern.

Nice solution just retrieving the HEAD that way -- it might even be
cached by the browser.

Thanks!!
Dan
Jan 29 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.