M
mscir
When I try to use the DOM to add an image to a table cell, it works in
IE but not in Netscape. If I look at the innerHTML of the table in
Netscape I see %5C in place of "\" in the image file path, nothing I do
corrects it. e.g.
<td><img src="C:%5CArchive%5Cgraphic%5C2pitvipers.jpg"></td>
Does anyone have any suggestions?
TIA,
Mike
<h3>Select Photo to Add to Table</h3>
<input type="file" name="imgsrc" id='imgsrc'
onchange="addRowToTable(this.value);">
function addRowToTable(photosrc){
alert(photosrc);
var tbl = document.getElementById('tblSample');
var lastRow = tbl.rows.length;
var iteration = lastRow;
var row = tbl.insertRow(lastRow);
// left cell
var cellLeft = row.insertCell(0);
var textNode = document.createTextNode(iteration);
cellLeft.appendChild(textNode);
// right cell
var cellRight = row.insertCell(1);
//attempt 1
//var el = document.createElement('img');
//el.setAttribute('src', unescape(photosrc));
//el.src=unescape(photosrc);
//cellRight.appendChild(el);
//attempt 2
cellRight.innerHTML="<img src='"+decodeURIComponent(photosrc)+"'>";
cellRight.innerHTML=decodeURIComponent(cellRight.innerHTML);
//attempt 3
//var el = new Image();
//el.src=unescape(photosrc);
//cellRight.appendChild(el);
}
<table border="1" id="tblSample">
<tr>
<th colspan="2">User Selected Photos</th>
</tr>
</table>
IE but not in Netscape. If I look at the innerHTML of the table in
Netscape I see %5C in place of "\" in the image file path, nothing I do
corrects it. e.g.
<td><img src="C:%5CArchive%5Cgraphic%5C2pitvipers.jpg"></td>
Does anyone have any suggestions?
TIA,
Mike
<h3>Select Photo to Add to Table</h3>
<input type="file" name="imgsrc" id='imgsrc'
onchange="addRowToTable(this.value);">
function addRowToTable(photosrc){
alert(photosrc);
var tbl = document.getElementById('tblSample');
var lastRow = tbl.rows.length;
var iteration = lastRow;
var row = tbl.insertRow(lastRow);
// left cell
var cellLeft = row.insertCell(0);
var textNode = document.createTextNode(iteration);
cellLeft.appendChild(textNode);
// right cell
var cellRight = row.insertCell(1);
//attempt 1
//var el = document.createElement('img');
//el.setAttribute('src', unescape(photosrc));
//el.src=unescape(photosrc);
//cellRight.appendChild(el);
//attempt 2
cellRight.innerHTML="<img src='"+decodeURIComponent(photosrc)+"'>";
cellRight.innerHTML=decodeURIComponent(cellRight.innerHTML);
//attempt 3
//var el = new Image();
//el.src=unescape(photosrc);
//cellRight.appendChild(el);
}
<table border="1" id="tblSample">
<tr>
<th colspan="2">User Selected Photos</th>
</tr>
</table>