diff --git a/js/youtube.js b/js/youtube.js index bb3aee26..d987803b 100755 --- a/js/youtube.js +++ b/js/youtube.js @@ -366,11 +366,17 @@ function setBGimage(id){ { $("#bgimage").css("background-image", "url(bg4.jpg);"); }else if(window.mozInnerScreenX == null && !window.mobilecheck()){ + var bg = new Image(); + bg.src = "http://img.youtube.com/vi/"+id+"/0.jpg"; $("#bgimage").addClass("noopacity"); - setTimeout(function(){ - $("#bgimage").css("background-image", "url(http://img.youtube.com/vi/"+id+"/0.jpg)"); - $("#bgimage").removeClass("noopacity"); - }, 1000); + console.log(bg); + bg.addEventListener("load", function(){ + setTimeout(function(){ + $("#bgimage").css("background-image", "url("+bg.src+")"); + //document.getElementById("bgimage").backgroundImage.src = bg.src; + $("#bgimage").removeClass("noopacity"); + }, 1000); + }); }else if(window.mobilecheck()){ $("#mobile-banner").css("background-image", "url(http://img.youtube.com/vi/"+id+"/hqdefault.jpg)"); $("#mobile-banner").css("width",$(window).width());