469,314 Members | 2,197 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,314 developers. It's quick & easy.

JS works in Safari, but not FF - DOM error

I've got a problem with a script that is working perfectly in Safari, but won't work in FF. The error it spits out is

Exception ``[Exception... "Node was not found" code: "8" nsresult: "0x80530008 (NS_ERROR_DOM_NOT_FOUND_ERR)" location: "https://***.net/~dhaggard/portal/js/checkPartition.js Line: 355"]'' thrown from function deletePartition(aPartID=string:"hdpart-1/1243", partHDrive=string:"hdpart-1") in <https://***.net/~dhaggard/portal/js/checkPartition.js> line 355.

Exception ``[Exception... "Node was not found" code: "8" nsresult: "0x80530008 (NS_ERROR_DOM_NOT_FOUND_ERR)" location: "https://***.net/~dhaggard/portal/js/checkPartition.js Line: 355"]'' thrown from function (null)() in <javascript:deletePartition('hdpart-1/1243','hdpart-1')> line 1.
Here is the function I'm trying to call...

Expand|Select|Wrap|Line Numbers
  1. function deletePartition (aPartID, partHDrive) {
  2.  
  3.     var oldPartHD = document.getElementById(partHDrive);
  4.     var oldPartition = document.getElementById(aPartID);
  5.  
  6.     oldPartHD.tBodies[0].removeChild(oldPartition);
  7.  
  8. }
I'm trying to convert a script written in Safari over to work in FF/IE. I've been using http://www.quirksmode.org/dom/w3c_core.html that page to make sure that all the functions I used are even supported, but I'm still getting a couple of errors. Does anyone know what may be a fix for this? Thanks!
Oct 15 '07 #1
11 2654
acoder
16,027 Expert Mod 8TB
I'm assuming the removeChild line is causing the error. Can you show the table with id "hdpart-1" and tr with id "hdpart-1/1243"?
Oct 15 '07 #2
Sure...

Expand|Select|Wrap|Line Numbers
  1. <table id="hdpart-1">
  2.     <tbody>
  3.         <tr id="hdpart-1/1234">
  4.             <td>Cell 1</td>
  5.             <td>Cell 2</td>
  6.             <td>Cell 3</td>
  7.             <td>Cell 4</td>
  8.             <td>Cell 5</td>
  9.             <td>Cell 6</td>
  10.             <td>Cell 7</td>
  11.             <td>Cell 8</td>
  12.             <td>Cell 9</td>
  13.         </tr>
  14.     </tbody>
  15. </table>
It's the removeChild() that's generating the error, though I don't know if that's what's causing it. All of the errors I've generated, while tinkering with it, have been the result of FF not being able to find the node to remove. Safari, however, can find it. So I'm fairly certain it's an easy fix, I just can't seem to figure it out.

Thanks for the help!
Oct 15 '07 #3
gits
5,390 Expert Mod 4TB
hi ...

is oldPartition ok? i mean is the node found before you try to remove it?

kind regards
Oct 17 '07 #4
mrhoo
428 256MB
strictly speaking, oldPartHD.tBodies[0].firstChild is a newline text node, not a tr element, and firefox is pretty strict with nodes.
Oct 17 '07 #5
gits
5,390 Expert Mod 4TB
strictly speaking, oldPartHD.tBodies[0].firstChild is a newline text node, not a tr element, and firefox is pretty strict with nodes.
hmmm ... that was my first thought too ... but firstChild isn't used here?
Oct 17 '07 #6
mrhoo
428 256MB
Your right gits- I think the trauma of working with a function named removePartition was too much for me!
Could it be that firefox isn't honoring an id with a slash in it?
"hdpart-1/1234">
Oct 17 '07 #7
gits
5,390 Expert Mod 4TB
Your right gits- I think the trauma of working with a function named removePartition was too much for me!
Could it be that firefox isn't honoring an id with a slash in it?
"hdpart-1/1234">
hmmm ... i tested it ... and it seems to be working with FF 2.0.0.8 ... strange problem indeed?
Oct 17 '07 #8
mrhoo
428 256MB
I could remove all but the last row in a table in firefox .
When the tBody.getElementsByTagName('tr') length is 1 I had to remove the tbody itself from the table.
Edit- nope, this works-
Expand|Select|Wrap|Line Numbers
  1. var T=document.getElementsByTagName('table')[0];
  2. var TB=T.tBodies[0];
  3. while(TB.lastChild)TB.removeChild(TB.lastChild)

removes all the trs and text nodes and leaves an empty tbody.

It is a puzzle.
Oct 17 '07 #9
drhowarddrfine
7,435 Expert 4TB
Could it be that firefox isn't honoring an id with a slash in it?
"hdpart-1/1234">
You are right. Slashes are not allowed in id names but I don't know what FF does when it encounters it.
Oct 17 '07 #10
gits
5,390 Expert Mod 4TB
You are right. Slashes are not allowed in id names but I don't know what FF does when it encounters it.
hi ...

without a doctype (in quirksmode) FF found the element by id ... may be with a doctype it could be a problem ... FF could be more strict with the code? Why is Safari doing it? as i said ... seems to be strange ...

@sdustinh: do you use a doctype? ...

kind regards
Oct 18 '07 #11
drhowarddrfine
7,435 Expert 4TB
With a doctype, Firefox is not being more strict, it's just following the rules of the 'document type definition'. Quirks mode, after all, is just an IE bug and not a real 'mode'. So whenever you code to a bug, you never know what will happen in any browser, such as Safari in this case.

Not that I'm saying that is the problem here, but a doctype is required of all modern web pages
Oct 18 '07 #12

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by ioneabu | last post: by
4 posts views Thread by Summercoolness | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.