Skip to content

Instantly share code, notes, and snippets.

@brunotavares
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brunotavares/38f66ebdc0f5351c4b99 to your computer and use it in GitHub Desktop.
Save brunotavares/38f66ebdc0f5351c4b99 to your computer and use it in GitHub Desktop.
IE <video> cloneNode() bug
<!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