www.webdeveloper.com
Results 1 to 3 of 3

Thread: Javascript Image preload problem

Hybrid View

  1. #1
    Join Date
    Apr 2010
    Location
    Texas
    Posts
    2

    Javascript Image preload problem

    I'm currently working on increasing the loading speed of a customers website. I know that using an image preload doesn't make the site faster, but I would like to use one so nobody sees his site naked.

    Here's what I got:

    Code:
    <!--javascript image pre-load-->
    <SCRIPT LANGUAGE="JavaScript">
    <!-- hide from non JavaScript Browsers
    
    function preloader() 
    
    {
    Image1= new Image();
    Image1.src = "images/logo.png";
    
    Image2 = new Image();
    Image2.src = "images/index/security-guard-computer.jpg";
    
    Image3 = new Image();
    Image3.src = "images/index/padv-conference-banner.jpg";
    
    Image4 = new Image();
    Image4.src = "images/index/security-guards.png";
    
    Image5 = new Image();
    Image5.src = "images/contract_security_services.png";
    
    Image6 = new Image();
    Image6.src = "images/private_security_services.png";
    
    Image7 = new Image();
    Image7.src = "images/corporate_commercial_security.png";
    }
    
    
    
    // End Hiding -->
    
    <!--end preload-->
    </SCRIPT>
    </head>
    <body onLoad="javascript:preloader()">
    There must be a mistake I'm making. I notice when I clear my browser cache and try loading the page that the images still appear visible while loading.
    I've done a lot of digging in the forums and through the internet and decided I just needed to ask.

    Any thoughts?

    You can visit the page at http://www.taurusprotection.com

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    No function, no onload necessary:
    Code:
    <script type="text/javascript">
    Image1= new Image();
    Image1.src = "images/logo.png";
    
    Image2 = new Image();
    Image2.src = "images/index/security-guard-computer.jpg";
    
    Image3 = new Image();
    Image3.src = "images/index/padv-conference-banner.jpg";
    
    Image4 = new Image();
    Image4.src = "images/index/security-guards.png";
    
    Image5 = new Image();
    Image5.src = "images/contract_security_services.png";
    
    Image6 = new Image();
    Image6.src = "images/private_security_services.png";
    
    Image7 = new Image();
    Image7.src = "images/corporate_commercial_security.png";
    </script>
    At least 98% of internet users' DNA is identical to that of chimpanzees

  3. #3
    Join Date
    Apr 2010
    Location
    Texas
    Posts
    2

    resolved

    Thanks fang, I believe that may have solved the problem.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles