I have an iframe nested in my main page. The iframe contains the following script:
var adfoxPlaceholderId = 'placeholder';
var adfoxWindow = window;
var adfoxDocument = window.document;
var adfoxPlaceholder = adfoxDocument.getElementById(adfoxPlaceholderId);
try {
while((adfoxPlaceholder == null) && (adfoxWindow != window.top)) {
adfoxWindow = adfoxWindow.parent;
adfoxDocument = adfoxWindow.document;
adfoxPlaceholder = adfoxDocument.getElementById(adfoxPlaceholderId);
}
} catch(ex) {
console.log('catch-block');
}
The script breaks on line adfoxDocument = adfoxWindow.document;
because of the security policy (the iframe and the main page are from different urls).
My question is why isn't this error caught by catch block as if it wasn't put into the try-catch block? Thank you.