F
F
fastweb2019-12-20 19:33:08
YouTube
fastweb, 2019-12-20 19:33:08

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

2 answer(s)
S
Shohruh Shaimardonov, 2019-12-20
@joeberetta

window.onload = function() {
  //elem думаю найдете сами с помощью querySelector() / getElementBy...
  elem.setAttribute('allowfullscreen', 'allowfullscreen')
}

N
Nadim Zakirov, 2019-12-21
@zkrvndm

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 question

Ask a Question

731 491 924 answers to any question