Last active
January 6, 2017 12:23
-
-
Save JustinDFuller/5a5572b1a59ef92db75cae0cdd2e72ac to your computer and use it in GitHub Desktop.
Reload A Video On Error
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
const videoElement = document.getElementById('myVideo'); | |
videoElement.onerror = onerror; | |
const errorButton = document.createElement('button'); | |
errorButton.setAttribute('type', 'button'); | |
errorButton.setAttribute('id', 'reload'); | |
errorButton.setAttribute('onclick', 'reloadVideo()'); | |
errorButton.textContent = 'Reload'; | |
errorButton.addEventListener("click", reloadVideo); | |
function onerror () { | |
videoContainer.appendChild(errorButton); | |
} | |
function reloadVideo () { | |
videoElement.load(); | |
videoContainer.removeChild(errorButton); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment