can't unescape image path in Netsacpe, adding image to td

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>
 
H

hugo2

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

Might try this:

src = "file:///[drive]:/[folder]/[path]/[fileName.ext]"

I got this from a software pro who responded to a
bug report I filed in Bugzilla.
It seems to be a universal path syntax that works
everywhere all the time.

good luck.
hugo2 ----
 
C

Chris

Hi Mike

This works for me on ie6 and Mozilla/5.0 (Windows; U; Windows NT 5.1;
en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax)

<code snip>

photosrc='file:///'+photosrc;
cellRight.innerHTML="<img src='"+photosrc+"'>";

</code snip>

Chris
 
M

mscir

Chris said:
Hi Mike

This works for me on ie6 and Mozilla/5.0 (Windows; U; Windows NT 5.1;
en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax)

<code snip>

photosrc='file:///'+photosrc;
cellRight.innerHTML="<img src='"+photosrc+"'>";

</code snip>

Chris

Thanks Chris, that works great!
Mike
 
M

mscir

hugo2 said:
Might try this:

src = "file:///[drive]:/[folder]/[path]/[fileName.ext]"

I got this from a software pro who responded to a
bug report I filed in Bugzilla.
It seems to be a universal path syntax that works
everywhere all the time.

good luck.
hugo2 ----

Thanks hugo2, just what I needed!
Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top