0

I have a page on which I used iframe to show PDF document, I want to throw error event if the PDF is not available. For this I used the onerror event. It is working fine in Firefox but IE doesn't detect the onerror event. I'm using mootools 1.1 as a Javascript library.

<html>
    <head>
        <script>
            var IframeHelper = (function () {
                return {
                    onLoaded: function (source) {
                        alert(source + ' loaded OK');

                /*    var get=document.getElementById('srcframe');
                      var gett=get.contentWindow.innerHTML;
                      if(gett!=null)
                      {
                      alert(gett + " content inside");
                      }
                      else
                      {
                        alert("some problme");
                      }
Added this because onerror was not launching for ie. So used this workaround
                */

                    },
                    onErrored: function (source) {
                        alert(source + ' failed to load');
                    }
                }
            }());
        </script>
    </head>
    <body>
        <iframe src="tst.pdf" id="srcframe" onload="alert('loads');IframeHelper.onLoaded(this.src);" onerror="alert('in');IframeHelper.onErrored(this.src);"></iframe>

    </body>
</html> 
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Kunal Vashist
  • 2,380
  • 6
  • 30
  • 59

1 Answers1

0

This is the common problem. In ie8 one cannot access errors from another frame.

Related question [SO]: Full callstack for multiple frames js on ie8

Community
  • 1
  • 1
kirilloid
  • 14,011
  • 6
  • 38
  • 52