puppeteer/third_party/phantomjs/test/www/regression/pjs-13551/reloading-parent.html
2017-05-11 00:06:41 -07:00

23 lines
750 B
HTML

<!doctype html>
<meta charset="utf-8">
<script>
function createIframe () {
var ifrm = document.createElement("iframe");
ifrm.setAttribute("src", "child1.html");
ifrm.setAttribute("id", "target");
document.body.appendChild(ifrm);
}
function receiveMessage (event) {
if (event.data == "execute") {
var element = document.getElementById("target");
element.contentWindow.location.href = "child2.html";
}
}
window.addEventListener("message", receiveMessage, false);
window.onload = function () {
document.getElementById("prepare").onclick = createIframe;
window.callPhantom(0);
}
</script>
<button id="prepare">Prepare the iframe</button>