SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2001
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PreLoading Scripts Fail to work

    I have a site that uses 2 different sets of preloading scripts. One, which appears on every page, and a second, smaller script which loads images specific to that page. A sample script can be found at http://www.fitnessforlife.com/musclegram.shtml

    The script reads as follows:

    <SCRIPT type="text/javascript" LANGUAGE=JavaScript>
    <!--
    image1 = new Image();
    image1.src = "images/musclebody3.gif";

    image2 = new Image();
    image2.src = "images/musclegram.gif";

    image3 = new Image();
    image3.src = "images/home.gif";

    image4 = new Image();
    image4.src = "images/email.gif";

    image5 = new Image();
    image5.src = "images/back.gif";
    //-->
    </SCRIPT>

    This is similar to the scripts found on all pages. The trouble is that it does not work worth a lick. Doesn't preload one d*&^ thing.

    I was wondering why? Is there something wrong with the coding?

    T

  2. #2
    SitePoint Guru siphilp's Avatar
    Join Date
    Nov 2001
    Location
    Fife, Scotland
    Posts
    663
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile Let the software do it for you....

    Afternoon,
    What you should do is download Macromedia Dreamweaver, Ultradev or normal doesn't matter which one, from here http://www.macromedia.com/downloads/ .
    Once installed etc you need to open it then look for the "window" menu, then "behaviours" this will open a little box with events actions shown. Click on + this will bring up another menu. If you look up the menu it will allow you to "preload Images" if you click on that a dialogue box opens and you can choose which images you want the broswer to pre load. The code it produces is non-sense but it works which is the main thing. I don't know if any of the good freeware WYSIWYG web editors has the same function or not?


    Hope this helps if not i am sure i can put together some code for you.


    Si Philp

  3. #3
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I found that trick never worked myself and ended up using the DW trick as well...the only form I use from DW but it works ALL the time.
    Code:
    function MM_preloadImages() { //v3.0
      var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
        if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }
    Thats the format you want to use to preload the images. ALSO make sure the original code is in the head. It looks fine but needs to be in the head to work. Also specify javascript1.2 and surround it in quotes.


    Code:
    MM_preloadImages('file:///C|/Documents%20and%20Settings/Apparition.BBS/My%20Documents/my%20web1/graphics/titlebg.gif')"
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.

  4. #4
    SitePoint Enthusiast
    Join Date
    Feb 2001
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Been there done that guys.

    Well sorta. Lemme explain.

    I use DW. I love it. And I tried your approach. The problem I ran into is this....None of my pages have a traditional body tag, which is traditionally where DW places the preload code, correct?

    You see, my body tag is a SSI and it shows up on every page. It contains the navigation dhtml menu. If I had the menu inserted individually on each page, then the body tag (which is contained in the menu script) could contain images specific to that page, but as it is, the body tag is the same for each page. I do not know if this makes sense, and if it doesn't I am sorry.

    Bottom line is if I try to use the behavior command, it ends creating <p> tags and inserting preloading script somewhere in the body of the page in said <p> tags (because it has no body tags to put them in....get it?)

    That is not gonna work. Or am I mistaken?

    Timmy


Bookmarks

Posting Permissions

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