Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Blocked a frame with origin
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
<div>
<h1>This is a IFrame</h1>
</div>
</body>
<script src="file.js"></script>
</html>
document.domain = "s3-website-sa-east-1.amazonaws.com";
window.alberto = {
nome: "Alberto",
idade: 26,
seApresentar: function() {
alert("Ola eu sou " + this.nome + " e tenho " + this.idade + " anos.")
}
};
setTimeout(function () {
var parent = window.parent;
parent.doAlert(window.alberto);
var h1Title = document.querySelectorAll("h1")[0];
h1Title.style = "color: red";
h1Title.textContent = "A mensagem foi enviada para a window.parent";
}, 2000)
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
<script src="file.js"></script>
</head>
<body>
<div>
<h1>This page hosts a IFrame</h1>
<hr />
<iframe src="http://crossiframesample2.s3-website-sa-east-1.amazonaws.com/" frameborder="1"></iframe>
</div>
</body>
</html>
document.domain = "s3-website-sa-east-1.amazonaws.com";
window.doAlert = function (pessoa) {
pessoa.seApresentar();
var h1Title = document.querySelectorAll("h1")[0];
h1Title.style = "color: red";
h1Title.textContent = "Pessoa recebida: " + pessoa.nome;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment