<!DOCTYPE html>
<html lang="en">
	<head>
		<title>Opener</title>
		<style>
			body {
				font-family: Arial, sans-serif;
				font-size: 16px;
				margin: 2em;
			}
			.grey {
				color: #BDBDBD;
			}
			.green {
				color: #43A047;
			}
		</style>
		<script>
			window.onload = function() {

				if (window.opener) {
					document.getElementById("opener").innerText = window.opener.location || window.opener;
					document.getElementById("opener").className = "green";
				} else {
					document.getElementById("opener").innerText = "Null";
				}

				if (window.name) {
					document.getElementById("name").innerText = window.name;
					document.getElementById("name").className = "green";
				} else {
					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>
	<body>
		<h2>HTTP</h2>
		&emsp;Referer: <?= $_SERVER["HTTP_REFERER"] ? '<span class="green">' . $_SERVER["HTTP_REFERER"] . '</span>' : '<span class="grey">None</span>' ?>
		<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>
