Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6
  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    5
    Member #
    29717
    Liked
    1 times
    Hello,
    I've just finished my website. But my random background images load properly sometimes, and sometimes they load as a half.
    Here is my website:
    http://www.finnhaverkamp.com/

    Here is the relevant HTML:
    Code:
    <!--open random background script-->
    <script  type="text/javascript">
    
    var randnum = Math.random();
    var inum = 7;
    var rand1 = Math.round(randnum * (inum-1)) + 1;
    var images = new Array;
    images[1] = "background1.jpg";
    images[2] = "background2.jpg";
    images[3] = "background3.jpg";
    images[4] = "background4.jpg";
    images[5] = "background5.jpg";
    images[6] = "background6.jpg";
    images[7] = "background7.jpg";
    var image = images[rand1];
     
    function chBackgr()
    {
        document.body.style.backgroundImage = 'url(' + image + ')';
    }
    
    onload = chBackgr;
    <!--close random background script-->
    It's weird. Because my background image is certainly random. It's just that sometimes only half of the image loads. Really strange. Any help is appreciated. Thank You.

  2.  

  3. #2
    Senior Member Ganners's Avatar
    Join Date
    Feb 2011
    Location
    United Kingdom
    Posts
    415
    Member #
    27007
    Liked
    92 times
    You just need to compress your images a bit more, they're a bit too high file size for web. e.g.

    http://www.finnhaverkamp.com/background5.jpg is 302.94KB

    With Photoshop > Save for web and devices > JPG @ 60% Quality (Considered high for web) it is 80.57kb (Still too high for web really though!) Medium quality is 38.25KB which is more like it.

    I guess you may also have some slow hosting, perhaps with a keep-alive-timeout on loads so your images will get so far then your connection to the server will die. Your JavaScript is fine though, it's too simple to fail really.
    Mark Gannaway Software Developer

    Recent Experiments
    - Backpropogation Neural Network language solving (http://ann.ganners.co.uk/)
    - Animated image to ASCII (http://google.ganners.co.uk/)
    - 3D Paper Characters (http://cybergame.ganners.co.uk/)
    - Anagram solving (http://roflol.co.uk/)

  4. #3
    Junior Member
    Join Date
    Oct 2011
    Posts
    5
    Member #
    29717
    Liked
    1 times
    Hello Ganners,
    thank you for your response. Though I'm not positive that is the answer.
    This same issue has been occuring the entire time, during my previewing in the browser before I ever started hosting the site.
    So, wouldn't that mean the file size is irrelevent, since everything loads instantly locally.
    I may be wrong. Please get back to me as you are able.

  5. #4
    Senior Member Ganners's Avatar
    Join Date
    Feb 2011
    Location
    United Kingdom
    Posts
    415
    Member #
    27007
    Liked
    92 times
    Oh that's odd, I'm at work now and I can see here the problem you were on about. Though this didn't occur for me at home (both in Chrome)! Umm, well your JavaScript is fine, you could try moving it to just before the end </body> tag and see if that makes a difference (sometimes it does putting it after the element it is to effect) other than that I'm not too sure at the moment. I'll take a look later.
    Mark Gannaway Software Developer

    Recent Experiments
    - Backpropogation Neural Network language solving (http://ann.ganners.co.uk/)
    - Animated image to ASCII (http://google.ganners.co.uk/)
    - 3D Paper Characters (http://cybergame.ganners.co.uk/)
    - Anagram solving (http://roflol.co.uk/)

  6. #5
    Junior Member
    Join Date
    Oct 2011
    Posts
    5
    Member #
    29717
    Liked
    1 times
    Hey, thanks for the suggestion. I just tried it, but no dice.
    With alittle more investigating, I've found that the first time an image loads, only half of it loads. Every time after that, the entire image loads. It does seem to be a file size problem, but I just don't see how.

  7. #6
    Senior Member Ganners's Avatar
    Join Date
    Feb 2011
    Location
    United Kingdom
    Posts
    415
    Member #
    27007
    Liked
    92 times
    They show up for me when I resize my browser which is quite odd. You could try making it validate:

    http://validator.w3.org/check?uri=ht...Inline&group=0

    Lots of errors! (297 of them)
    Mark Gannaway Software Developer

    Recent Experiments
    - Backpropogation Neural Network language solving (http://ann.ganners.co.uk/)
    - Animated image to ASCII (http://google.ganners.co.uk/)
    - 3D Paper Characters (http://cybergame.ganners.co.uk/)
    - Anagram solving (http://roflol.co.uk/)


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 05:16 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com