Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2008-10-01
3
Medium Priority
?
684 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

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

618 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