473,401 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

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

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

Similar topics

2
by: David | last post by:
On every web browser except Safari, this website works great. (Well, by "every" I mean Mozilla, Netscape, and Internet Explorer, for Mac and Windows). The site is: http://www.ruleofthirds.com ...
4
by: ioneabu | last post by:
I am trying to do the basic task of setting a text field from the choice made from a select box. I learned how to code it from my O'Reilly Javascript reference which is a few years old. The code...
2
by: JThomas | last post by:
Hello! I'm having trouble with a page apparently causing my client's Safari browser to time out. I don't actually have access to a Mac & Safari, and haven't been able to physically see this...
4
by: metoikos | last post by:
I've scoured the web (clumsily, I'm sure) for information on the difficulties I am having, checked my markup in validators, and had a friend with more CSS clue look over it, but I haven't had any...
6
by: digleif | last post by:
I'm struggling to fix an annoying CSS problem. I've built a nav bar in a table and use css to control the hover state, which colours the background of the table cell. In every browser I've...
6
by: munchit | last post by:
HI Folks, New here but i've followed a few other threads in the past so hoped someone could help! Have a new site design that seems to work fine in FF/Safari/IE6 but not IE7... i'm not sure...
4
by: Summercoolness | last post by:
does anyone know why this CSS works in IE 7 but not Firefox or Safari? (it works weird in Firefox and Safari) <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://...
2
by: JDeats | last post by:
>From my development envrionment (i.e. a single WinXP notebook PC) I have a basic AJAX application that is making the call to a Windows Form page that just returns the request back to the AJAX...
1
by: Gretsch | last post by:
I have modelled my program on the std code below (from http://www.w3schools.com/dom/dom_parser.asp).. It works in IE & Firefox, but does not work with Safari - nor does Safari issue the alert...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.