473,473 Members | 1,425 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

removeChild error

43 New Member
Hi,
so i got script like that

Expand|Select|Wrap|Line Numbers
  1. var div_box = document.createElement("div");
  2. div_box.setAttribute("id", "music_box");
  3. div_box.style.top = (Number(cords[1]) - 10) + "px";
  4. div_box.style.left = (Number(cords[0]) - 10) + "px";        
  5. document.body.appendChild(div_box);
  6.  
  7. var mb_element = document.createElement("div");
  8. mb_element.setAttribute("id", "mb_element");
  9. mb_element.innerHTML = "Test";
  10. $.id("music_box").appendChild(mb_element);
  11.  
  12. $.addEventListener($.id("music_box"), "mouseout", function() {
  13.     document.body.removeChild($.id("music_box"));
  14. });
  15.  
and when mouseout i got this error on mozilla firebug

Expand|Select|Wrap|Line Numbers
  1. [Exception... "Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsIDOMHTMLBodyElement.removeChild]" nsresult: "0x80004003 (NS_ERROR_INVALID_POINTER)" location: "JS frame :: http://msounds.lietuvoje.com/main_js.js :: anonymous :: line 365" data: no]
  2. [Break on this error] document.body.removeChild($.id("music_box"));
  3.  
what is wrong????
Apr 29 '08 #1
5 5544
pronerd
392 Recognized Expert Contributor
I do not think the "$." is legal syntax in JavaScript. Also the removeChild() function is supposed to have the element to be removed passed to it, not the element's ID attribute. call should look like this.

Expand|Select|Wrap|Line Numbers
  1.     document.body.removeChild(div_box);
  2.  
Apr 29 '08 #2
tader
43 New Member
well it does remove box when i use
Expand|Select|Wrap|Line Numbers
  1. document.body.removeChild(div_box); 
but then i get error like this
Expand|Select|Wrap|Line Numbers
  1. Node was not found" code: "8
  2. [Break on this error] document.body.removeChild(div_box);
  3.  
Apr 30 '08 #3
pronerd
392 Recognized Expert Contributor
but then i get error like this
Expand|Select|Wrap|Line Numbers
  1. Node was not found" code: "8
  2. [Break on this error] document.body.removeChild(div_box);
  3.  
Are you calling that line more than once? If so that is likely the problem. Once an element has been removed it can not be removed again. Also are you still using "$." in your code?
Apr 30 '08 #4
tader
43 New Member
o ok i understand the problem ty for your help
Apr 30 '08 #5
acoder
16,027 Recognized Expert Moderator MVP
I'm not sure about $., but $() is definitely legal if you're using Prototype. You can grab one element or a number of elements using the $ function.
May 1 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: JehanNYNJ | last post by:
I need to clear out the HTML contents of a <span> element and then re-add that element as a blank span. Here is the code... var elem = document.getElementById(spanId); var deletedElem =...
2
by: Stewart | last post by:
Originally posted in comp.lang.javascript: Newsgroups: comp.lang.javascript From: "Stewart" Date: 23 Aug 2005 02:50:04 -0700 Local: Tues, Aug 23 2005 10:50 am Subject: FireFox, RemoveChild,...
1
by: mike | last post by:
I am trying to remove a row in a parent window from a child window. Is this possible? var row_delete = self.opener.document.getElementById("Action_Row_4"); var rows =...
4
by: VA | last post by:
I have the following code (modified) from RobG on this newsgroup... function moveColumn(table_id,col_id, dir) { var table=document.getElementById(table_id); var idx=GetCellIndex(col_id,table);...
5
by: Markus Stehle | last post by:
Hi all! I want to remove a node from a nodelist by using RemoveChild. I'm using the following code: XmlNode root = Xml.DocumentElement; XmlNodeList items = root.SelectNodes("Item"); XmlNode...
1
by: Rebecca Tsukalas | last post by:
Hello, I have a problem concerning removeChild. This is the XML structure I use with php: <xml_thing <language1 <site>bla1</site <site>bla2</site <site>bla3</site </language1
6
by: VK | last post by:
I must be missing something very obvious, but my nightly head doesn't work anymore. Press "Insert" button to add <insnodes after each <br>. Now press "Delete" - only even <insare being removed....
10
by: r_ahimsa_m | last post by:
Hello, On index.html page I have a table with id="property_fields". <table id="property_fields" name="property_fields" border="0"> It contains set of rows with the following IDs: var...
5
by: r_ahimsa_m | last post by:
Hello, I am lerning HTML/CSS/JavaScript. I created HTML page with table "property_fields" containing 24 rows ('tr' elements). I want to remove last 23 rows: var table =...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.