Created
November 13, 2019 17:02
-
-
Save prof3ssorSt3v3/03afdac50303f2417c157a439a558922 to your computer and use it in GitHub Desktop.
This file contains 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
<!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>Using iFrames</title> | |
</head> | |
<body> | |
<p><button id="btn">Click to Pause/Play</button></p> | |
<iframe id="frm" src="vid-frame.html" height="300px" width="500px"></iframe> | |
<script> | |
document.addEventListener("DOMContentLoaded", () => { | |
let frm = document.getElementById("frm"); | |
console.log(frm); | |
frm.addEventListener("load", ev => { | |
console.log(ev.target.contentDocument); | |
let vid = ev.target.contentDocument.getElementById("player"); | |
console.log(vid); | |
let btn = document.getElementById("btn"); | |
btn.addEventListener("click", ev => { | |
if (vid.paused) { | |
vid.play(); | |
} else { | |
vid.pause(); | |
} | |
}); | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment