javascriptiframe-resizer

Error handling in iframe-resizer?


I use iframe-resizer to insert content(jsf-pages) in iframe. So, how to detect that server responsed with 404 not found?

Is there some callback or other way to detect this?


Solution

  •  const iframeResizerOptions = {
        log: true,
        checkOrigin: true,
        initCallback: (iframe) => {
          if (iframe.contentDocument.getElementsByClassName("error-title").length > 0) {
            onError();
          } else {
            onLoad();
          }
        },
      };
    

    You may use initCallback and get iframe from input parameter.