Solved

.RemoveChild functioning in IE, throwing a Pointer error in FF

Posted on 2008-10-01
3
674 Views
Last Modified: 2013-12-07
I have a little snippet of code that is throwing an error in Firefox, but functioning fine in IE. Basically, it's a rating system. Once a user rates the item, the rating area needs to be removed. IE does this, but in Firefox I get the following error:


[Exception... "Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsIDOMHTMLDivElement.removeChild]"  nsresult: "0x80004003 (NS_ERROR_INVALID_POINTER)"  location: "JS frame :: :: jsUpdateHTML :: line 31"  data: no]

Can't seem to figure out what is throwing this in FF.  


var l_dStars = document.getElementById( "dStars" );

	for( var l_iCt = 1; l_iCt <= 5; l_iCt++)

		l_dStars.removeChild( document.getElementById( "dStar"+l_iCt ) );

Open in new window

0
Comment
Question by:dangermonkey
3 Comments
 
LVL 82

Expert Comment

by:hielo
ID: 22616533
try:
var l_dStars = document.getElementById( "dStars" );
      for( var l_iCt = 1; l_iCt <= 5; l_iCt++)
            deleteNode("dStar"+l_iCt );

function deleteNode(elementId){
  var e=document.getElementById(elementId);
  if(!e)
   return;
  while( e.hasChildNodes() ) { e.removeChild( e.lastChild ); }
}
0
 
LVL 18

Accepted Solution

by:
Morcalavin earned 250 total points
ID: 22616655
Are you removing all its' children, or just the first five?  If all of them, you could try this:

var l_dStars = document.getElementById( "dStars" );
while(l_dStars.firstChild)
{
    l_dStars.removeChild(l_dStars.firstChild);
}


0
 

Author Closing Comment

by:dangermonkey
ID: 31502045
Thank you so much! That worked perfectly!!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
This article offers some helpful and general tips for safe browsing and online shopping. It offers simple and manageable procedures that help to ensure the safety of one's personal information and the security of any devices.
Google currently has a new report that is in beta and coming soon to Webmaster Tool accounts. This Micro Tutorial will highlight new features for Google Webmaster Tools.
How to create a custom search shortcut to site-search Experts Exchange using Google in the Firefox browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch your Bookmark Menu: Press 'Ctrl +…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now