diff --git a/Shared/Article Rendering/main.js b/Shared/Article Rendering/main.js index ea627c54b..6104a5a5a 100644 --- a/Shared/Article Rendering/main.js +++ b/Shared/Article Rendering/main.js @@ -45,6 +45,16 @@ function wrapTables() { } } +// Add the playsinline attribute to any HTML5 videos that don"t have it. +// Without this attribute videos may autoplay and take over the whole screen +// on an iphone when viewing an article. +function inlineVideos() { + document.querySelectorAll("video").forEach(element => { + element.setAttribute("playsinline", true) + element.setAttribute("controls", true) + }); +} + // Remove some children (currently just spans) from pre elements to work around a strange clipping issue var ElementUnwrapper = { unwrapSelector: "span", @@ -120,6 +130,7 @@ function styleLocalFootnotes() { function processPage() { wrapFrames(); wrapTables(); + inlineVideos(); stripStyles(); convertImgSrc(); flattenPreElements(); diff --git a/iOS/Resources/main_ios.js b/iOS/Resources/main_ios.js index 269dc0ce0..4f7b0f8ee 100644 --- a/iOS/Resources/main_ios.js +++ b/iOS/Resources/main_ios.js @@ -130,19 +130,8 @@ function showClickedImage() { window.webkit.messageHandlers.imageWasShown.postMessage(""); } -// Add the playsinline attribute to any HTML5 videos that don"t have it. -// Without this attribute videos may autoplay and take over the whole screen -// on an iphone when viewing an article. -function inlineVideos() { - document.querySelectorAll("video").forEach(element => { - element.setAttribute("playsinline", true) - element.setAttribute("controls", true) - }); -} - function postRenderProcessing() { ImageViewer.init(); - inlineVideos(); } window.addEventListener('DOMContentLoaded', (event) => {