1 Reply Latest reply on Sep 12, 2013 12:34 PM by gkaiseril

    Using css into javascript preloader

    framode

      i need a code in javascript that loads an image and gives it a css style, so i wrote this code:

       

      function resizeGame() {

           var imageObj = new Image();

           imageObj.onload = function () {

                var sty3 = "content:url(1.jpg); width:100%; position:relative; z-index:-100;"

                var obj2 = document.getElementById("sfondo");

                obj2.setAttribute("style", sty3);

           };

      imageObj.src = '1.jpg';

      }

       

      The code works, but i want to know if it really preloads my image correctly, i'm not so sure... thaks a lot

      Francesco