It is true that regular javascript cannot access the contents of the iframe in another domain for security reasons. However , this in no way stops user scripts in Chrome, Tampermonkey or Greasemonkey.
iframed- , Chrome ( Firefox) iframe' , . , .
, , domain_A.com:
<html>
<body>
<iframe src="http://domain_B.com/SomePage.htm"></iframe>
</body>
</html>
@match :
// @match http://domain_A.com/*
// @match http://domain_B.com/*
script - iframe, .
, script :
if (/domain_A\.com/i.test (document.location.href) ) {
document.body.style.setProperty ("background", "lime", "important");
}
else {
document.body.style.setProperty ("background", "pink", "important");
}
-, iframed - .
, :
if (window.top === window.self) {
//--- Code to run when page is the main site...
}
else {
//--- Code to run when page is in an iframe...
}
( ), Chrome. !. , . "" , , , .