Solved

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

Posted on 2008-10-01
3
675 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I had to do a bit of research to find the answer to this question so I thought I'd share my results.  Due to our outdated mainframe systems, we need to downgrade IE9 to IE8 in order to stay compatible.  We also needed to downgrade Java.  In order to…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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.
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.

867 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

21 Experts available now in Live!

Get 1:1 Help Now