Last active
August 29, 2015 14:23
-
-
Save brunotavares/38f66ebdc0f5351c4b99 to your computer and use it in GitHub Desktop.
IE <video> cloneNode() bug
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Test</title> | |
</head> | |
<body> | |
<script type="text/javascript"> | |
// create a video node without auto-play | |
var originalVideoNode = document.createElement("video"); | |
originalVideoNode.autoplay = false; | |
originalVideoNode.controls = true; | |
originalVideoNode.innerHTML = '<source src="http://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">'+ | |
'<source src="http://www.w3schools.com/html/mov_bbb.ogg" type="video/ogg">' + | |
'Your browser does not support HTML5 video.'; | |
document.body.appendChild(originalVideoNode); | |
// play | |
originalVideoNode.play(); | |
// after a couple seconds playing, create a clone | |
window.setTimeout(function() { | |
var ghostNode = originalVideoNode.cloneNode(true); | |
document.body.appendChild(ghostNode); | |
// SURPRISE! In IE, the clone will be playing on the same spot as the parent | |
// Other browsers, the new node will be paused at the beginning. | |
}, 5000); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment