Solved

creating an image element in FireFox

Posted on 2007-12-03
2
505 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Visual Studio npm 1 29
ModalPopup  question 22 38
Put POST values into cookies. 14 34
javascript and jquery question 4 24
In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
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…

749 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