Solved

creating an image element in FireFox

Posted on 2007-12-03
2
506 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This article discusses how to implement server side field validation and display customized error messages to the client.
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…

690 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