Created
October 26, 2018 15:42
-
-
Save jchip/10d006c5ce5e5d22761f66f3d78e7181 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script> | |
var baseUrl = "http://localhost:3000"; | |
var launchedWindow; | |
function load() { | |
// window.location = "${baseUrl}"; | |
console.log("launching") | |
} | |
function launch() { | |
if (typeof BroadcastChannel === "undefined") return load(); | |
var bc = new BroadcastChannel(baseUrl); | |
setTimeout(load, 500); | |
function receiveMessage(evt) { | |
if (evt.data === "ping") { | |
console.log("got ping"); | |
// open("", "_self").close(); | |
window.open('', '_parent', ''); | |
window.close(); | |
bc.postMessage("pong"); | |
} else if (evt.data === "pong") { | |
console.log("got pong"); | |
// window.close(); | |
} | |
} | |
bc.onmessage = receiveMessage; | |
bc.postMessage("ping"); | |
} | |
launch(); | |
</script> | |
</head> | |
<body></body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment