vendredi 1 juillet 2016

JavaScript inserting images using string variable as their URL


I'm using JavaScript to parse a XML file. One of the XML's attribute is an URL which links to an image. eg. http://localhost/pic.jpg

As the parsing goes on, I use an variable to hold each URL(which is a string variable) and hoping that I can show these images in a table.

The following is part of my code:

for(i = 0; i < row.length; i++)
{
   // looping through the XML file
   var Logo1 = row[i].getElementsByTagName("Logo")[0].childNodes[0].nodeValue;
   //Logo1 is the string which is a URL
   document.write("<img src= 'Logo1' width='256' height='128'>");
}

I use Chrome, but the images won't load.... enter image description here

Can someone help?


Aucun commentaire:

Enregistrer un commentaire