JavaScript URL
The javascript
:imageData method was offered by Martin Webb on the comp.lang.javascript newsgroup when I asked for help. This uses a javascript url to supply the value for the src= attribute of an IMG element, or for the .src property of an Image object. The data is neither written nor encoded, it is simply supplied as the result of a javascript expression. Thus we may write a url as:
javascript
:'GIF89a\1\0\1\0\200[...]\1\0;'
which specifies a gif as a javascript literal string. Or we might store that data into a global variable:
var imageDataVar = 'GIF89a\1\0\1\0\200[...]\1\0;'
and then write the url as:
javascript
:imageDataVar
which references the value of the variable. Or we might write a function which returns the image data string and write the url as:
javascript
:functionReturningImage()
which calls the function to supply the image data.
The drawbacks of this method are that it is browser specific; that it doesn't cache well; that it cannot be used for multiple images on the same page unless special efforts are made to keep Netscape from running multiple threads in the JavaScript interpreter.
Partager