MediaWiki:Gadget-YouTubeLazy.js — различия между версиями
WikiSysop (обсуждение | вклад) |
WikiSysop (обсуждение | вклад) |
||
Строка 1: | Строка 1: | ||
− | function | + | window.LazyLoadYoutubeOnClick = function(id, w, h) { |
if (w == undefined) { w = 350 }; if (h == undefined) { h = 267 }; | if (w == undefined) { w = 350 }; if (h == undefined) { h = 267 }; | ||
var code='<iframe width="'+w+'" height="'+h+'" src="https://www.youtube.com/embed/'+id+'/?autoplay=1&autohide=1&border=0&wmode=opaque&enablejsapi=1" frameborder=0 allowfullscreen></iframe>'; | var code='<iframe width="'+w+'" height="'+h+'" src="https://www.youtube.com/embed/'+id+'/?autoplay=1&autohide=1&border=0&wmode=opaque&enablejsapi=1" frameborder=0 allowfullscreen></iframe>'; |
Текущая версия на 14:55, 29 апреля 2015
window.LazyLoadYoutubeOnClick = function(id, w, h) { if (w == undefined) { w = 350 }; if (h == undefined) { h = 267 }; var code='<iframe width="'+w+'" height="'+h+'" src="https://www.youtube.com/embed/'+id+'/?autoplay=1&autohide=1&border=0&wmode=opaque&enablejsapi=1" frameborder=0 allowfullscreen></iframe>'; var iframe = document.createElement('div'); iframe.innerHTML=code; iframe=iframe.firstChild; var div=document.getElementById("lazy-yt-"+id); div.parentNode.replaceChild(iframe, div) }