You know when you visit some forums and when you click on a link like this http://thecelebrityspotlight.com/attachment.php?attachmentid=64134&stc=1&thumb=1, they open up an image file and when you right click and save some how the image name appears ? There are no clues in the url that tells you what the image name is suppose to be and somehow magically the browser knows.
Well it appears that the browser is looking for the Content-Disposition header in the Http Response. Jim Ley @ jibbering.com has a page Using the XML HTTP Request Object, that describe how to get the headers using the XmlHttpRequest object.
For Firefox this code snippet should work. Read his blog post for more information.
var xmlhttp=new XMLHttpRequest();
xmlhttp.open("HEAD", "/faq/index.html",true);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
alert("Content Disposition: "+
xmlhttp.getResponseHeader("Content-Disposition"));
}
}
xmlhttp.send(null)