?
Solved

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

Posted on 2008-10-01
3
Medium Priority
?
681 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 1000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…
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 +…
Suggested Courses

765 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