Lasse said:
You do.
While the content of the string looks like C-code (or C++), it is also
exactly the format of XBM images (apparently someone thought it would
make it easier to include images in C programs if they were C code
aready).
The "Javscript:" pseudo protocol is interpreted by the browser to mean
"evaluate the javascript expression and use the resulting string as
the result of the link". In this place, Gecko tries to detect the
format of the resulting image, and correctly detects it as an XBM
image.
I would prefer a data: URL instead, which would also be much shorter
(and I would avoid using the proprietary feature of continuting a
string literal over several lines by ending lines with backslashes).
Break! :-D
As I said in the original "Santa Time" thread, one is welcome to use
any graphics instead or even simple colored div squares - it has
absolutely no effect on timing issues I wanted to demonstrate.
I just wanted (besides the original task) to make dynamic XBM images to
work - and I wanted to conduct a kind of survey on their support among
browsers and platforms. IE had some vulnerabilty to them, so since XP
SP2 this method doesn't work anymore. This alas renders the whole
method rather useless for a wide run.
url(data) from CSS2 is more convenient, but currently fully supported
by Opera only AFAIK. Also IE had some vulnerability to this too, so
this option is currently locked - and even if unlocked it will be under
the IE's GET length limit (20?? - you look) so one can render this way
only really tiny images.
Continuting a string literal over several lines by ending lines with
backslashes is not a proprietary feature of a particular browser. It is
an exploit of the core mechanics of how script source is being
delivered from the server and how script tokenizer works. No one
browser with script support - starting with the oldest ones - has a
chance to follow the relevant ECMA spec in this case. For this the
tokenizer algorythm has to be re-written - but it will break too many
of currently existing and perfectly valid scripts. As such string is
being treated as one literal instead of multiple concatenations, one
gets a tremendous productivity raise. Another question that if one
needs a huge string literal inside script then there must be something
wrong with the concept.