1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
;;;
;;; WML::preload - Preload Page Contents
;;;
;;; Package from WML <URL:http://www.engelschall.com/sw/wml/>
;;; wml::des::preload - Preload Page Contents
;;; Copyright (c) 1997 Ralf S. Engelschall, All Rights Reserved.
;;; Copyright (c) 2000-2003, Denis Barbier
;;;
<use name="WML:javascript" />
<set-var __pl:count=0 />
<define-tag preload whitespace=delete>
<preserve src via />
<set-var via=size />
<set-var %attributes />
<increment __pl:count />
<when <string-eq "<get-var via />" "size" />>
<img name="preload_img_<get-var __pl:count />" ;;;
src="<get-var src />" ;;;
width="1" height="1" alt="" />
</when>
<when <string-eq "<get-var via />" "js" />>
<copy-var src __pl:src />
;;; the group tag prevents deletion of newlines
<group "
<javascript>
if (document.images) {
preload_img_<get-var __pl:count /> = new Image();
preload_img_<get-var __pl:count /> = \"<get-var __pl:src />\";
}
</javascript>
" />
</when>
<restore src via />
</define-tag>
##EOF##
__END__
=head1 NAME
WML:preload - Preload Images
=head1 SYNOPSIS
<use name="WML:preload" />
<preload src="image filename" via="trick" />
=head1 DESCRIPTION
This include file provides the C<E<lt>preloadE<gt>> tag which can be used to
preload images. Such preloading is usually done to speedup access for following
pages. Currently there are only a few tricks how this can be done.
The following combinations are currently supported:
=over 4
=item C<src=>I<anyimage> C<via=size>
Preloads the image I<anyimage> by using an C<E<lt>imgE<gt>> tag with the
attributes C<width=1 height=1> which leads to the loading of the image but
only to a 1 pixel in display.
Advantage: Works for all browsers.
Disadvantage: This approach has the nasty side-effect of an occuring 1 pixel
in display because C<width=0 height=0> does not work as expected in most
browsers (especially in Netscape 4.x). So, position your C<E<lt>preloadE<gt>>
tag somewhere it does not destroy the look and feel of your page.
=item C<src=>I<anyimage> C<via=js>
Preloads the image I<anyimage> by using a JavaScript snippet which loads
the image by declaring an unused C<Image> object.
Advantage: Silently preloads the image without displaying anything.
Disadvantage: Only works for browsers with a JavaScript implementation and
only for those who support the C<Image> object (currently NS/3, NS/4, IE/4).
=back
=head1 AUTHORS
Ralf S. Engelschall
rse@engelschall.com
www.engelschall.com
Denis Barbier
barbier@linuxfr.org
=cut
|