Installation of asynchronous downloaded cs background



  • Objective: Asynchronously download the imagination and fill it as a background element. Baseline:

    var image = document.images[0];
    var downloadingImage = new Image();
    downloadingImage.onload = function(){
      // set sourc as css ?? 
            // = this.src;
    };
    downloadingImage.src = "/images/login/12.JPG";
    <style>
        .login-layout-transparent {
            background: url(images/loading.gif) 50% no-repeat;
    </style>



  • We're pulling styles out of line src Images, new images, JS, give it to him src and put it in the block, and we'll have the block removed. background

    <div class='img' background='none'></div>
    
    .img { background: url(img.jpg); }
    
    img = new Image();
    

    image = document.querySelector('.img');
    style = window.getComputedStyle(image);
    img.src = style.backgroundImage.slice(5, -2);
    image.style.background = 'none';

    img.onload = function() {
    image.appendChild(img);
    // image.outerHTML = img.outerHTML; // Если блок не нужен, заменяем его изображением
    }


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2