Window (iFrame) to catch error

Hi all.
I’m using DHTMLX windows loading in a iframe.
Now i’m trying to catch server errors.

I tried:

win.attachURL(url, false); win.getFrame().onerror=function(){alert(1); }

I tried to attach addEventListener too.

But nothing solved my problem.
Do you know if its possible to catch 404/500 server errors when using dhtmlx window with iframes?



function doOnLoad() { dhxWins = new dhtmlXWindows(); w1 = dhxWins.createWindow("w1", 20, 30, 320, 200); w1.attachURL("attached_page.html"); } function doOnError() { console.log(arguments); }


<script> window.onerror = function(){ parent.doOnError.apply(parent, arguments); } var a = 1+b; </script>

more docs here … oadedevent

Hi Andrei,
many thanks for your solution.
Problem still is that i can’t catch native 404 errors this way.
My solution that makes me hapyy so far is to check if dhtmlx is
loaded within the attached_page.
If not, its a 404 for me, cause all attached pages require dhtmlx.

Well, unfortunately there is no certain method for this. You can try the following:


w3.attachEvent("onContentLoaded", function(){ var loaded = false; try { loaded = (w3.getFrame().contentWindow.isNeededPage == true); } catch(e){}; if (loaded == true) { // your code here } else { // 404 } });


<script> var isNeededPage = true; </script>

or parse any other object or you can specify document.title and check for it value after load