Re: Preloading Images

Subject: Re: Preloading Images
From: Dan Morrison <dman@xxxxxxxx>
Date: Tue, 18 Jul 2000 13:37:16 +1200
Sia Rahimi wrote:

> I would like to generate the following html snippet:
> 
> <body bgcolor="#ffffff" onLoad="PreloadImages
> ('images/image1.gif','images/image2.gif','images/image3.gif');">

I would predict a few headaches getting your quoting right using that
approach. It can be done (reasonably easily) but I'd advise stepping out
of the onload to get it done.

<body bgcolor="#ffffff" onLoad="doPreloadImages()" >

<script>
function doPreloadImages(){
  Preload('images/image1.gif');
  Preload('images/image2.gif');
  Preload('images/image3.gif');
}
</script>

This means you won't have to contend with nested "''"

A template could be of the form:

<xsl:template match="LeftNavList">
  <script>
    function doPreloadImages(){
    <xsl:for-each select="PreLoadImage">
      Preload('<xsl:value-of select="." />');
    </xsl:for-each>
    }
  </script>
</xsl:template>


Advantages include clearer readability (IMO, although it can be
compressed back into your original PreloadImages(..,..,..) if you
prefer)
and it means the LeftNavList can be matched at any point in the page,
instead of attaching itself to the 'body' template.

There are more elaborate (generic) approaches and also more succinct
ways, like your original, but hopefully this will give you enough
pointers.

cheers,

.dman.


:=====================:====================:
: Dan Morrison        : The Web Limited    :
:  http://here.is/dan :  http://web.co.nz  :
:  dman@xxxxxxxx      :  danm@xxxxxxxxx    :
:  04 384 1472        :  04 495 8250       :
:  025 207 1140       :                    :
:.....................:....................:
: If ignorance is bliss, why aren't more people happy?
:.........................................:


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread