Update background after all items are loaded


quark

My problem is that my web application loads large images as background. It is applied in <style>the label at the top of the bodylabel. It works, but when opening the page, it shows a white background when the image is loaded.

I wanted to be able to set the image to a specific blue color background-colorwhen loading the image , so I did this:

Before the closing body tag:

     <script type="text/javascript">
        $(document).foundation();
        $(document).ready(function() {
            document.body.style.backgroundImage="url('img/form_bg.jpg')";
            //$('body').css('background-image', 'url(img/form_bg.jpg) no-repeat center center fixed');
        });
    </script>

However, this code won't work and the background won't load. This insists:

body {
    /*background:transparent;*/
    background-color:#2f3255;
}

How can I achieve:

  1. Make background color: #2f3255, when image loads
  2. After loading the image, change the background to the image
Kapanchak

You can add an extra div to the DOM ( #intro) which will cover the entire screen when the background image loads:

CSS:

#intro {
   width: 100%;
   position: fixed;
   top: 0;
   bottom: 0;
   z-index: 100;
   background-color:#2f3255;
}

Then, when the page loads, just hide that div:

$(window).load(function() {
    // You could add a time out here if you like (setTimeout(function() { $('#intro').fadeOut();   }, 500))
    $('#intro').fadeOut();    
});

Related


Update background after all items are loaded

quark My problem is that my web application loads large images as background. It is applied in <style>the label at the top of the bodylabel. It works, but when opening the page, it shows a white background when the image is loaded. I wanted to be able to set t

Update all list items

Jelle Note that I am new to programming. So I created a list (children) for all the child sprites in the game (children) and then another list (childrenSpeed) which stores each millisecondsPerFrame float value of the child sprites, The value is also attached t

Update the main UI when all are loaded

curse The problem is as follows, it executes another form but uses the main form, so the program becomes "unusable". I tried to use background worker but after discovering this method and switching. private async void Disp_data_Sim() { var

Update the main UI when all are loaded

curse The problem is as follows, it executes another form but uses the main form, so the program becomes "unusable". I tried to use background worker but after discovering this method and switching. private async void Disp_data_Sim() { var

Remove all items after indexing

Starkers: I have an array: array = ['mario','luigi','kong'] I call its splice function to remove all items before the index : array.splice(1) //-> ['luigi','kong'] I'm just wondering if there is a function similar to splice to remove all items after the inde

Remove all items after indexing

Starkers: I have an array: array = ['mario','luigi','kong'] I call its splice function to remove all items before the index : array.splice(1) //-> ['luigi','kong'] I'm just wondering if there is a function similar to splice to remove all items after the inde

Remove all items after indexing

stronger I have an array: array = ['mario','luigi','kong'] I call its splice function to remove all items before the index : array.splice(1) //-> ['luigi','kong'] I'm just wondering if there is a function similar to splice to remove all items after the index

Remove all items after indexing

Starkers: I have an array: array = ['mario','luigi','kong'] I call its splice function to remove all items before the index : array.splice(1) //-> ['luigi','kong'] I'm just wondering if there is a function similar to splice to remove all items after the inde

Check all images loaded after .ajax request?

Gidi Minas I need to know when all images are loaded from the attached html source to perform other functions. How can I check? $(document).ready(function () { $('a.load-more').click(function (e) { e.preventDefault(); $.ajax({ type: "GET",

resolve promise after all images are loaded

Ursus I am using the following code to preload images: function preLoad() { var deferred = $q.defer(); var imageArray = []; for (var i = 0; i < $scope.abbreviations.length; i++) { imageArray[i] = new Image();

resolve promise after all images are loaded

Ursus I am using the following code to preload images: function preLoad() { var deferred = $q.defer(); var imageArray = []; for (var i = 0; i < $scope.abbreviations.length; i++) { imageArray[i] = new Image();

Capture page after all content is loaded asynchronously

code dog I'm new to PhantomJS and trying to capture Trade Me 's homepage . Here is my code so far: var page = require('webpage').create(); page.open('http://trademe.co.nz', function () { // Checks for bottom div and scrolls down from time to time window.

Angular - call function after all JS is loaded

User 1857116 I want to call a function when all files (JS) are loaded (because I want to call a function inside one of the files). How do I do this? .state('dashboard', { url: "/dashboard.html", templateUrl: "views/dashboard.html",

Angular - call function after all JS is loaded

User 1857116 I want to call a function when all files (JS) are loaded (because I want to call a function inside one of the files). How do I do this? .state('dashboard', { url: "/dashboard.html", templateUrl: "views/dashboard.html",

Use Deferred after all products are loaded

detas12 I have a page with a carousel that sends an ajax request every time a slide changes and generates the products related to the slide into another carousel at the bottom. At the moment after each slide change, the product is drawn successfully using Ajax

Call mounted after all properties created are loaded

Anix In my Vue app, I fetch some data from a remote API and use that data to create a Html table. I decided to go with the following process. Get the data from created()the API in the hook and set the data property there, then in the mounted()hook call the met

Check all images loaded after .ajax request?

Gidi Minas I need to know when all images are loaded from the attached html source to perform other functions. How can I check? $(document).ready(function () { $('a.load-more').click(function (e) { e.preventDefault(); $.ajax({ type: "GET",

resolve promise after all images are loaded

Ursus I am using the following code to preload images: function preLoad() { var deferred = $q.defer(); var imageArray = []; for (var i = 0; i < $scope.abbreviations.length; i++) { imageArray[i] = new Image();

Capture page after all content is loaded asynchronously

code dog I'm new to PhantomJS and trying to capture Trade Me 's homepage . Here is my code so far: var page = require('webpage').create(); page.open('http://trademe.co.nz', function () { // Checks for bottom div and scrolls down from time to time window.

Capture page after all content is loaded asynchronously

code dog I'm new to PhantomJS and trying to capture Trade Me 's homepage . Here is my code so far: var page = require('webpage').create(); page.open('http://trademe.co.nz', function () { // Checks for bottom div and scrolls down from time to time window.