Improve and reformat opener

This commit is contained in:
ReimarPB 2023-02-14 20:25:24 +01:00
parent fc370b9e61
commit 0c745d758b
2 changed files with 37 additions and 13 deletions

9
opener/iframe.html Normal file
View File

@ -0,0 +1,9 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Opener</title>
</head>
<body>
<iframe src="index.php" width="500" height="800"></iframe>
</body>
</html>

View File

@ -19,7 +19,7 @@
window.onload = function() {
if (window.opener) {
document.getElementById("opener").innerText = window.opener;
document.getElementById("opener").innerText = window.opener.location || window.opener;
document.getElementById("opener").className = "green";
} else {
document.getElementById("opener").innerText = "Null";
@ -32,6 +32,13 @@
document.getElementById("name").innerText = "Empty String";
}
if (document.referrer) {
document.getElementById("referrer").innerText = document.referrer;
document.getElementById("referrer").className = "green";
} else {
document.getElementById("referrer").innerText = "Empty string";
}
}
</script>
</head>
@ -41,6 +48,14 @@
<h2>JavaScript</h2>
&emsp;window.opener: <span id="opener" class="grey">Enable JavaScript</span>
<br><br>
&emsp;document.referrer: <span id="referrer" class="grey">Enable JavaScript</span>
<br><br>
&emsp;window.name: <span id="name" class="grey">Enable JavaScript</span>
<h2>Test yourself</h2>
&emsp;<a href="#" onclick="window.open(location.href)">window.open()</a>
<br><br>
&emsp;<a href="/opener">&lt;a&gt;</a>
<br><br>
&emsp;<a href="/opener/iframe.html">&lt;iframe&gt;</a>
</body>
</html>