У меня есть JavaScript на моем сайте Weebly.com. Один из них - Tubular, который добавляет видео фона к выбранному элементу. Но он не всегда загружается правильно и не всегда запускается. Иногда это происходит, как правило, не при освежении, но когда я открываю новое окно в Chrome и загружаю сайт.
Что я вижу в Chrome при нажатии CTRL + SHIFT + J.
Calling CSSStyleSheet.insertRule() with one argument is deprecated. Please pass the index argument as well: insertRule(x, 0).
Consider using 'dppx' units instead of 'dpi', as in CSS 'dpi' means dots-per-CSS-inch, not dots-per-physical-inch, so does not correspond to the actual 'dpi' of a screen. In media query expression: only screen and (-webkit-min-device-pixel-ratio: 2), not all, not all, not all, only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) (index):1
Consider using 'dppx' units instead of 'dpi', as in CSS 'dpi' means dots-per-CSS-inch, not dots-per-physical-inch, so does not correspond to the actual 'dpi' of a screen. In media query expression: only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 144dpi) (index):1
Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('http://www.youtube.com') does not match the recipient window origin ('https://www.youtube.com').
event.returnValue is deprecated. Please use the standard event.preventDefault() instead.
Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('http://www.youtube.com') does not match the recipient window origin ('https://www.youtube.com').
Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('http://www.youtube.com') does not match the recipient window origin ('https://www.youtube.com'). www-widgetapi-vflZ5Tu3E.js:26
Мой порядок загрузки скриптов на внешних файлах находится непосредственно перед тегом закрывающего тела над остальными сценариями.
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script type="text/javascript" src="/files/theme/jquery_tubular.js"></script>
<script type="text/javascript" src="/files/theme/smoothscroll.js"></script>
<script type="text/javascript" src="/files/theme/bigtext.js"></script>
Это сценарий в моем HTML файле, который требует видео. Код Tubular находится в jquery_tubular.js. См. Код в приведенной выше ссылке JSFiddle.
<script type="text/javascript">
jQuery().ready(function() {
jQuery('#video-bg').tubular({videoId: 'a2pu_xhBnzY});
});
</script>
"Эта проблема (я полагаю) связана с тем, что YT api не возбуждает его готовое событие".
Просто измените window.onYouTubeIframeAPIReady = function() в функции setTimeout
window.onYouTubeIframeAPIReady = function() {
setTimeout(function(){
player = new YT.Player('tubular-player', {
width: options.width,
height: Math.ceil(options.width / options.ratio),
videoId: options.videoId,
playerVars: {
controls: 0,
showinfo: 0,
modestbranding: 1,
wmode: 'transparent'
},
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
},600);
};
Я нашел решение здесь: https://code.google.com/p/jquery-tubular/issues/detail?id=31