Skip to content

Instantly share code, notes, and snippets.

@mattdesl
Created November 4, 2019 15:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattdesl/ce08fc060422c2bd13c69386177d727a to your computer and use it in GitHub Desktop.
Save mattdesl/ce08fc060422c2bd13c69386177d727a to your computer and use it in GitHub Desktop.
window / parent / child
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
</head>
<body>
<input
id="slider"
oninput="handleChange()"
type="range"
min="0"
max="1"
step="0.01"
/>
<script>
const mySlider = window.slider;
window.sliderValue = mySlider.value;
function handleChange() {
window.sliderValue = mySlider.value;
}
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
</head>
<body>
<script>
let childWindow;
window.addEventListener("click", () => {
childWindow = window.open("controller.html");
});
setInterval(() => {
if (childWindow) {
console.log("Current value", childWindow.sliderValue);
}
}, 250);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment