Answer the question
In order to leave comments, you need to log in
How to automatically substitute allowfullscreen="allowfullscreen" in a YouTube video?
Such a problem through the opencart admin panel, when uploading a product, videos are inserted initially without allowfullscreen="allowfullscreen",
Because of this, it is not possible to switch to full-screen video mode. Manually edit this crap every time. How can the problem be solved? Can the script somehow substitute the machine? Maybe someone has such a script or another solution...
Answer the question
In order to leave comments, you need to log in
window.onload = function() {
//elem думаю найдете сами с помощью querySelector() / getElementBy...
elem.setAttribute('allowfullscreen', 'allowfullscreen')
}
Place the code on the page:
<script type="text/javascript">
// Дожидаемся готовности стр. и выполняем код в функции:
document.addEventListener('DOMContentLoaded', function() {
// Ищем все youtube-фреймы на странице:
all_iframe = document.querySelectorAll('iframe[src*="youtube"]');
// Обходим все найденные фреймы в цикле и присваиваем атрибут:
for (i = 0; i < all_iframe.length; i++) {
all_iframe[i].setAttribute('allowfullscreen', 'allowfullscreen');
}
});
</script>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question