Source code

Revision control

Copy as Markdown

Other Tools

<!doctype html>
<html>
<head>
<title>Bug 1813463: Web controlled about:blank</title>
</head>
<!--
This work is marked with CC0 1.0. To view a copy of this license,
-->
<body>
<p><a href="#" id="document_write">document.write example</a></p>
<p><a href="#" id="innerhtml">innerHTML example</a></p>
<script>
document.getElementById("document_write").addEventListener("click", function (aEvent) {
aEvent.preventDefault();
let popup = window.open("about:blank", "_blank", "width=800,height=600,popup");
popup.document.write(`
<h1>check security info</h1>
<p>initial window.location = ${popup.location}</p>
<script>
document.write("<p>new window.location = " + window.location + "</p>")
<${"/"}script>
`);
});
document.getElementById("innerhtml").addEventListener("click", function (aEvent) {
aEvent.preventDefault();
let popup = window.open("about:blank", "_blank", "width=800,height=600,popup");
popup.stop();
popup.document.body.innerHTML = `
<h1>check security info</h1>
<p>window.location = ${popup.location}</p>`;
});
</script>
</body>
</html>