How to get iframe response headers?

12,095

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.

Share:
12,095
Admin
Author by

Admin

Updated on June 20, 2022

Comments

  • Admin
    Admin almost 2 years

    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!