473,396 Members | 1,892 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,396 software developers and data experts.

referencing images with javascript

2
Hi i have the following code that works fine in firefox but not IE?

function imgLoad ()
{
test = new Image();
test = "../gfx/nav_es/areas_over.gif";
document.getElementById('test').src = test;
}

<body onLoad="imgLoad()">

<img src="../gfx/nav_es/humano_over.gif" name="test" id="test">

i have also tried

function imgLoad ()
{
test = new Image()
test = "../gfx/nav_es/areas_over.gif"
document.images['test'].src = test;
}

but with no result. I think it goes without saying i'm learning this for the first time.

any help would be greatly appriciated.
Jan 31 '07 #1
2 1430
b1randon
171 Expert 100+
Hi i have the following code that works fine in firefox but not IE?

function imgLoad ()
{
test = new Image();
test = "../gfx/nav_es/areas_over.gif";
document.getElementById('test').src = test;
}

<body onLoad="imgLoad()">

<img src="../gfx/nav_es/humano_over.gif" name="test" id="test">

i have also tried

function imgLoad ()
{
test = new Image()
test = "../gfx/nav_es/areas_over.gif"
document.images['test'].src = test;
}

but with no result. I think it goes without saying i'm learning this for the first time.

any help would be greatly appriciated.
The problem is that you're assigning "test" to a new Image object, then RE-assigning "test" to "../gfx/nav_es/areas_over.gif". Something like this should fix your problem:
Expand|Select|Wrap|Line Numbers
  1. function imgLoad ()
  2. {
  3.     var test = new Image();
  4.     test.src = "../gfx/nav_es/areas_over.gif";
  5.     document.images['test'].src = test.src;
  6. }
  7.  
Jan 31 '07 #2
oroojo
2
b1randon - I was aging at an alaming rate sat here, I can not thank you enough!
Jan 31 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Simon | last post by:
Am using the following code. <script language="JavaScript1.2"> function setquantity(productindex,productquantity) { //create the reference object irefname_none = eval("document." +...
1
by: Lucanus | last post by:
Hi All, Just a quick question, which should have a simple answer... Can I have a document with three images with the same name, and reference those images individually. ie: <img...
2
by: Marcus | last post by:
I am after what is probably very basic help. Below is the HTML including the bit of Java I am trying to understand why its not working. The idea is as the mouse moves over and off the "button"...
3
by: Lyners | last post by:
I have a table within a cell of a datagrid. I am doing updates without postback to the server using Javascript. I have everything working, except referencing a table within the datagrid cell. ...
2
by: Tom | last post by:
I need to be able to reference some images stored in my VB.NET program. Normally, I would load the images into an ImageList control and use them from there (these are going to be icons). However, I...
1
by: WB | last post by:
Hi, I would like to do something like this page: http://www.stocklayouts.com/Products/Postcard/Postcard-Template-Design-Library.aspx?kwid=38 Notice when you mouse-over any of the icons under...
2
tjc0ol
by: tjc0ol | last post by:
Hi guys, I have here a javascript code that is capable of changing one background image when link is clicked, it goes: <script type="text/javascript" language="javascript"> var bgImg = new...
5
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.