Matthew Grima
Matthew Grima

Reputation: 1523

jQuery iframe.load status

Is there a way I can find whether there's an http error status inside an iframe?

I'm loading the iframe with a dynamically built url and am removing a loading gif on load.

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

All of this is ok, but in the event of an error inside this page, I would like to show my own error text rather than what gets shown inside the iframe.

Is this possible?

UPDATE Note that the iframe will always be loaded on a different domain.

Upvotes: 3

Views: 1173

Answers (2)

Matthew Grima
Matthew Grima

Reputation: 1523

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

I went down a route similar to this:

Resizing an iframe based on content

Upvotes: 0

Asherlc
Asherlc

Reputation: 1161

I don't believe this is possible in the way you're hoping, but what about an interval that checks the contents? Something like:

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

Upvotes: 1

Related Questions