By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,504 Members | 1,176 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,504 IT Pros & Developers. It's quick & easy.

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

P: n/a
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.i nnerHTML);
//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>
Sep 10 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
hugo2, sept 10, 2005
mscir wrote:
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 ----

Sep 10 '05 #2

P: n/a
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

"mscir" <ms***@yahoo.com> wrote in message
news:5a********************@pghconnect.com...
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.i nnerHTML);
//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>

Sep 10 '05 #3

P: n/a
Chris wrote:
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
Sep 11 '05 #4

P: n/a
hugo2 wrote:
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
Sep 11 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.