Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 433
Matthew Grima Avatar asked Jan 18 '26 17:01

Matthew Grima


1 Answers

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)
like image 102
Asherlc Avatar answered Jan 20 '26 13:01

Asherlc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!