473,385 Members | 1,357 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Images in Javascript variables

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.

Oct 30 '06 #1
3 1397
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/
Oct 30 '06 #2
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. :-|

Oct 30 '06 #3
VK

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.

Oct 30 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Orest Kinasevych | last post by:
Okay, I made sense of the earlier suggestions and realized I was on the right track -- I appreciate the feedback which got me to this point. The suggestions posted here indeed worked and...
10
by: John Ortt | last post by:
Hi Everyone, I have created a Javascript menu for my site which uses frames. The first stage loads fine but I want two drill down menus ("About Me Menu" and "Projects Menu"). The pages load...
9
by: josvanr | last post by:
HI I'm working on a site http://www.josvanriswick.nl/nieuw in which i use absolute positioning. On my pc at home i didn't notice, but now, as the site is on air and loading images is a bit...
2
by: windandwaves | last post by:
Hi Gurus Preloading images has got to be JS 101. However, it does not seem to be working. Here is the function that I am using. I added the alerts to make sure it is working and all the right...
15
by: Geoff Cox | last post by:
Hello I have following type of code in the header function pre_load_pics() { if (document.images) { var image1 = new Image(400,265); image1.scr = "pic1.jpg";
5
by: vanisathish | last post by:
Hi I have an application, which has to change to different images based on some conditions. I am trying to call a javascript function(this function changes the images on the front end) from the...
2
by: John | last post by:
Hi all, I'm having a problem loading images for later use in javascript on the client. In my code-behind, I'm using a stringbuilder object to build and populate a few javascript variables like :...
0
by: Daniel Wellesley | last post by:
Can anyone help me with this problem: I am trying to preload images, but I am not doing them the traditional way (which works fine): <script language=javascript> var myImage = new Image()...
3
by: littleark | last post by:
Hi everybody, I have a typical javascript images preloader, it works fine both on Firefox and on IE in my intranet (local server). It works fine on the Internet (remote server) in IE. In...
11
by: bdbeames | last post by:
What I have is a is two sets of images,(Weather, optical) there is about 30 images of is each set. I have script that will rotate through the images on the main page. The user is able to view...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.