Is there a way to get response headers of an iframe onload?
I have already googled it, but really I could not find something useful about it!
Is there a way to get response headers of an iframe onload?
I have already googled it, but really I could not find something useful about it!
Not really. If the iframe is on the same domain you can access its document object which contains some useful information such as document.referrer
, but you cannot intercept the full HTTP headers without making an Ajax request for the URL. This would mean requesting the URL again. e.g:
$.ajax( { url: $(#myFrame).attr('src'), success: function(r,x){
console.log( x.getResponseHeader('SomeHeader') );
} } );
This will only work if the iframe src is in the same domain as the calling script.
If you have control on the loaded iframe resource you can dump the header content on a postMessage request to the main window.