JQuery iframe.load status

Is there a way to find if there is an http error status inside the iframe?

I am loading an iframe with a dynamically rendered url and removing the loading gif on load.

$("#reportFrame").load(function () {
        kendo.ui.progress($("#report-container"), false)
        $('#btnReportRefresh').removeAttr('disabled').removeClass('k-state-disabled');
        $(this).css('display', 'block');
    });

      

This is all fine, but in case of an error inside this page, I would like to show my own error text, not what is displayed inside the iframe.

Is it possible?

UPDATE Please note that the iframe will always load on a different domain.

+3


source to share


2 answers


I forgot about this question, but here's an update.

I went down a route like this:



Resize iframe based on content

0


source


I don't think this is as possible as you hope, but what about an interval that checks the content? Something like:



setInterval(function() {
  if ($("#reportFrame body").html() === "This is an error page") {
    // Do Something
  } else {
    //Do something else
}, 500)

      

+1


source







All Articles