Solved

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

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

Independent Software Vendors: 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

Suggested Solutions

Title # Comments Views Activity
Need help with this homework problem. 5 62
How to get CSS styled menu to maintain the open selected menu? 13 46
ModalPopup  question 22 39
window close link 7 36
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
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 +…

730 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