Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Images in Javascript variables

Reply
Thread Tools

Images in Javascript variables

 
 
Pete
Guest
Posts: n/a
 
      10-30-2006
Hi,

I have some image data in a Javascript variable, and I want to display
it. I have a technique which works in Firefox but not in Internet
Explorer :

<script>
var testImage = <image data as a string>
</script>

<img src="javascript:testImage"></img>


I understand that this should work in Javascript 1.2 and above, which
supports null characters in strings. Does anyone know why this doesn't
work in Internet Explorer?

Many thanks,
Pete.

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      10-30-2006
Pete wrote:

> I have some image data in a Javascript variable, and I want to display
> it. I have a technique which works in Firefox but not in Internet
> Explorer :
>
> <script>
> var testImage = <image data as a string>
> </script>
>
> <img src="javascript:testImage"></img>
>
>
> I understand that this should work in Javascript 1.2 and above, which
> supports null characters in strings. Does anyone know why this doesn't
> work in Internet Explorer?


It is nowadays not as much a question of the JavaScript version but of
the browser supporting javascript: URLs for the HTML img element. I
think older versions of IE used to support XBM but newer don't, and IE
has never supported rendering GIF or JPG or PNG image data in a
javascript: URL as the src attribute value of an HTML img element.

--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
Pete
Guest
Posts: n/a
 
      10-30-2006
Martin Honnen wrote:
>
> It is nowadays not as much a question of the JavaScript version but of
> the browser supporting javascript: URLs for the HTML img element. I
> think older versions of IE used to support XBM but newer don't, and IE
> has never supported rendering GIF or JPG or PNG image data in a
> javascript: URL as the src attribute value of an HTML img element.
>


Thanks for the reply. So I guess the only way I could do it is to
somehow save the data to a file then point the img element at the file?

Hmmm.

 
Reply With Quote
 
VK
Guest
Posts: n/a
 
      10-30-2006

Pete wrote:
> So I guess the only way I could do it is to
> somehow save the data to a file then point the img element at the file?


It depends on what kind of picture is that. If it's a raster photo then
I'm affraid so (or use server-side bitmap generator).

If it's a vector graphics (or something that can be represented as
vector graphics w/o nuking the parser) then you can use SVG/VML markup
or drawing commands.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Put variables into member variables or function variables? tjumail@gmail.com C++ 9 03-23-2008 04:03 PM
Help with Javascript: naming variables using other variables sagejoshua HTML 16 11-09-2005 12:27 PM
Track Images added to images folder and subfolders - send out email alerts ASP .Net 4 01-04-2005 10:01 PM
Preloading Images into Javascript variables =?Utf-8?B?RGFuaWVsIFdlbGxlc2xleQ==?= ASP .Net 0 08-07-2004 08:03 AM
Preloading Images into Javascript variables =?Utf-8?B?RGFuaWVsIFdlbGxlc2xleQ==?= ASP .Net 0 08-04-2004 03:15 AM



Advertisments