Martin Honnen wrote:
<snip>
And IE/Win for instance doesn't support
<img src="javascript:...">
<snip>
That isn't quite true (though for all practical purposes it is). IE can
do javascript
: SRCs on images, but only when the image format is XBM.
XBM being an image format where the data is defined as text, so a long
way form being an efficient form as it takes 5+ characters to define a
byte. It is also a two color format (black and transparent):
var trash = "#define trash_width 16\n#"+
"define trash_height 16\n"+
"static char trash_bits[] = {"+
"0x00,0x01,0xe0,0x0f,"+
"0x10,0x10,0xf8,0x3f,"+
"0x10,0x10,0x50,0x15,"+
"0x50,0x15,0x50,0x15,"+
"0x50,0x15,0x50,0x15,"+
"0x50,0x15,0x50,0x15,"+
"0x50,0x15,0x10,0x10,"+
"0xe0,0x0f,0x00,0x00"+
"};";
....
<img src="javascript
:trash" width="16" height="16" alt="Trash Can">
Mozilla is much happier with this general idea and will show
(apparently) any recognised graphic format. E.G.:-
var crossGif =
"\u0047\u0049\u0046\u0038\u0039\u0061\u002b\u0000" +
"\u002b\u0000\ufff0\u0000\u0000\ufffd\u0000\u0000" +
"\uffff\uffff\uffff\u0021\ufff9\u0004\u0001\u0000" +
"\u0000\u0001\u0000\u002c\u0000\u0000\u0000\u0000" +
"\u002b\u0000\u002b\u0000\u0040\u0002\u0078\uff8c" +
"\uff8f\uff99\uffa0\uffed\u000f\u000d\uff8b\ufff4" +
"\u004d\u0075\u0057\uff8d\u0019\ufff5\ufff3\u006d" +
"\u0055\u0028\uff96\uff9e\uff89\u0036\u0064\u006a" +
"\u0069\uffa7\u0008\uffc4\ufff2\u004c\uffd7\ufff6" +
"\u006d\u006f\uffdd\uffce\uff96\u006b\u004f\ufff9" +
"\u0001\u0021\uffc2\uffe1\uffa2\u0066\u0054\u0029" +
"\u0031\uffc6\uff95\u0013\ufff8\u0074\u0014\uff83" +
"\u004b\u0057\uffd2\uff83\uffbc\u0052\uffb5\u003a" +
"\u006e\uffd7\uffbb\u0005\u0013\uffc5\u001c\ufff2" +
"\uffd8\u002c\u0045\uff83\u002e\uffec\uffa9\uffe9" +
"\u0003\uffbf\uff92\uffe6\uffc3\u0068\u0035\u0065" +
"\u0067\ufff6\ufff2\u0056\u007c\u002b\u000d\u0005" +
"\uffa8\uffd7\u0034\u0008\u0002\u0016\u0063\u0028" +
"\uffe1\u0056\uffa7\u0076\uffd7\u0028\ufff1\uffd8" +
"\u0017\uffb9\uffa8\u0045\uffa9\u0050\u0000\u0000" +
"\u003b";
....
<img src="javascript
:crossGif" width="43" height="43"
alt="Cross Hairs (red)">
However, it is interesting to observe that the byte data from the
graphic is in the lower byte of the 16 bit Unicode character escapes
(some of which need to be padded, e.g. \uffa8, in order to keep that low
byte negative). I suspect that taking the responseText of an XML HTTP
request (nominally UTF-8) and making a javascript string out of it will
garble any data that was originally binary beyond being useful, even in
Mozilla.
Opera doesn't seem to be interested in javascript
: SRCs at all, and is
unlikely to be alone in that.
Richard.