An answer to \"Foolproof way to detect if iframe is cross domain\" describes a method to test if an iframe on a page points to a same-domain or cross-domain page, working ar
Real cross-browser solution for posterity:
function isCrossOriginFrame() { try { return (!window.top.location.hostname); } catch (e) { return true; } } console.log(isCrossOriginFrame());
Tested on a decent swath of desktop and mobile browsers.
https://jsfiddle.net/arzd4btc/3/