Solved

creating an image element in FireFox

Posted on 2007-12-03
2
503 Views
Last Modified: 2012-05-05
Hi,

I have written some simple code that creates an image element, assigns the src and appends it to an existing element. Now this works fine in IE but not firefox.  Please coul some shed some light on this and a possible solution.

Below is my code:

Andrew
function AddImage(imageNumber, imageUrl)
{
    var o = document.getElementById("Image"+imageNumber);
    o.parentNode.className = "HasPhoto";
    var imageNode = document.createElement("image");
    imageNode.src = imageUrl; 
    o.appendChild(imageNode); //this only works in IE for some reason
    if(imageNumber!=3)
    {
        var nextObj= imageNumber+=1;
        document.getElementById("Image"+nextObj).parentNode.className = "FirstPhoto";
    }
}

Open in new window

0
Comment
Question by:REA_ANDREW
2 Comments
 
LVL 82

Accepted Solution

by:
hielo earned 500 total points
ID: 20396600
Try this:

function AddImage(imageNumber, imageUrl)
{
    var o = document.getElementById("Image"+imageNumber);
    o.parentNode.className = "HasPhoto";
    var imageNode = document.createElement("img");
    imageNode.src = imageUrl;
    o.appendChild(imageNode); //this only works in IE for some reason
    if(imageNumber!=3)
    {
        var nextObj= imageNumber+=1;
        document.getElementById("Image"+nextObj).parentNode.className = "FirstPhoto";
    }
}
0
 
LVL 20

Author Comment

by:REA_ANDREW
ID: 20397217
lol ofcourse!!!!! nice one for that, I have had a total lapse in brain activity!!! thanks again

Andrew
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now