Skip to content

Instantly share code, notes, and snippets.

@dougkeeling
Created July 10, 2018 13:23
Show Gist options
  • Save dougkeeling/146e90a484aa3310cae2b2ed3753fe7d to your computer and use it in GitHub Desktop.
Save dougkeeling/146e90a484aa3310cae2b2ed3753fe7d to your computer and use it in GitHub Desktop.
[Make background videos work in iOS/Android] Script to be placed in footer #video #php #mobile #html
// Place in footer
var mobilevideo = document.getElementsByTagName("video");
var i;
for (i = 0; i < mobilevideo.length; i++) {
mobilevideo[i].setAttribute("playsinline", "");
}
// Alternate, gets only the first video
var mobilevideo = document.getElementsByTagName("video")[0];
mobilevideo.setAttribute("playsinline", "");
mobilevideo.setAttribute("muted", "");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment