473,666 Members | 2,728 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"Node was not found" error

When I visit the following webpage:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test</title>
</head>

<body>
<div id="demo">this is a test...</div>
<script>
result = document.create Element("span") ;
result.style.co lor = "#f00";
result.style.fo ntWeight = "bold";
result.appendCh ild(document.cr eateTextNode(" ...that has been a
success"));

var demo = document.getEle mentById("demo" );

demo.parentNode .replaceChild(d emo,result);
</script>
</body>

I get this error (in FF2):

uncaught exception: [Exception... "Node was not found" code: "8"
nsresult: "0x80530008
(NS_ERROR_DOM_N OT_FOUND_ERR)" location:
"http://www.domain.tld/test.html Line: 17"]

Nov 9 '06 #1
2 14373

yawnmoth wrote:
When I visit the following webpage:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test</title>
</head>

<body>
<div id="demo">this is a test...</div>
<script>
result = document.create Element("span") ;
result.style.co lor = "#f00";
result.style.fo ntWeight = "bold";
result.appendCh ild(document.cr eateTextNode(" ...that has been a
success"));

var demo = document.getEle mentById("demo" );

demo.parentNode .replaceChild(d emo,result);
</script>
</body>

I get this error (in FF2):

uncaught exception: [Exception... "Node was not found" code: "8"
nsresult: "0x80530008
(NS_ERROR_DOM_N OT_FOUND_ERR)" location:
"http://www.domain.tld/test.html Line: 17"]
Take a closer look at this:

http://developer.mozilla.org/en/docs...t.replaceChild

The parameters should be replaceChild(ne w, old) and you've got
replaceChild(ol d, new).

Also I would discourage you from using script tags within the <body>
section of your document, unless you have a good reason to do so (and
there aren't many). Put the <scripttag in the <headsection and
wrap your code in a window.onload handler, like this:

<head>
<title>Test</title>
<script>
window.onload = function() {
var something = document.getEle mentById('somet hing');
// ... code goes here
}
</script>
</head>
<body>
<div id="something"> </div>
</body>
</html>

Check out http://www.onlinetools.org/articles/...ivejavascript/
for some good, modern Javascript style.

Nov 9 '06 #2
David Golightly said the following on 11/9/2006 5:39 PM:

<snip>
Also I would discourage you from using script tags within the <body>
section of your document, unless you have a good reason to do so (and
there aren't many). Put the <scripttag in the <headsection and
wrap your code in a window.onload handler, like this:
<snip>
<script>
window.onload = function() {
var something = document.getEle mentById('somet hing');
// ... code goes here
}
</script>
And you call that "good, modern Javascript style" to leave out the type
attribute (which is mandatory)? No feature detection. Hmmm.

Also, could you please explain how to wrap code in a function that uses
document.write to add advertisement to pages and fire it onload without
wiping out the page?

<snip>
Check out http://www.onlinetools.org/articles/...ivejavascript/
for some good, modern Javascript style.
If the free chapter is indicative of the entire book, no thanks.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 10 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
511
by: Ari Royce Hidayat | last post by:
Dear ALL, Is there some one ever faces this problem? And fix it? The scenario is: There's an html page that hosts a .net object (using object tag), and this page opens the second html page that also hosts a .net object (e.g. by click a hyperlink).
2
3637
by: Paul T. RONG | last post by:
Hi, It is very strange. The mde works very well in Access XP but will get "Module not found" error when closing a form in Access 2k. I tried from yesterday evening to solve this prolem but in vain. Any help will be greatly appreciated. Thanks.
4
1971
by: mattsthompson | last post by:
Im writing a DLL that extends IHttpHandler to intercept requests for a certain file extension and deliver watermarked images. I'm using LeadTools' .NET framework for the image manipulation and it is their Codecs.Load which issues the error. I have the code working when the image is loaded from my local machine but when loading from a network share I receive a File Not Found error from the framework that is attempting to load then file...
1
1650
by: Casper Stendal | last post by:
Is it some how possible to handle a "directory not found" error through ASP.NET (or ASP), without having to make speciel a setup for the application in IIS, when it comes from an URL without extension, like this: http://www.mywebpage.com/folder/notfound/ Any comments are preciated?
2
7586
by: johkar | last post by:
Why does if(win==null || win.closed) return true after one PDF is open. Something very wierd going on with IE 6. I also get a member not found error if a child window is already open. This script works fine if the child window contains HTML, just not a PDF. Ideas? Note: These are not my PDFs, I just found some on the Net so you could test. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"...
6
3658
Tarantulus
by: Tarantulus | last post by:
if("dept"=='dept'){ document.getElementById('add').style.display='none'; }; <DIV id="add"> <some html here..> </DIV>
8
3259
by: webgenius | last post by:
Whenever I click the SUBMIT button in my HTML page, I get the "Object not found!" error. It was working fine yesterday. This error started to occur after I installed Codelobster and made some changes to the php file CheckLogin.php. This is a small part of the HTML page with the button: When I enter the username and password and click on the Submit button, I get the error: Plase help me on this.
3
8395
by: masterofzen | last post by:
I've been playing around with this for a while. I bet the answer is pretty obvious, but I'm just not seeing it. I'm also reasonably certain I've run into this problem before. I'm trying to dynamically insert a few nodes into a webpage using insertBefore. Here's the HTML in question. (Yes, I know the HTML is terrible, but I didn't write it and can't edit it, which is why I have to insert things through the DOM instead. Long story.) <div...
0
2569
by: Brian Lampe | last post by:
On Apr 11, 7:25 am, subhash <chend...@hotmail.comwrote: If your service is using a port other than 80, you can specify it in the service instantiation's Url property: http://msdn2.microsoft.com/en-us/library/ms153652.aspx From this example, ReportingService2005 rs = new ReportingService2005();
3
5659
maliksleo
by: maliksleo | last post by:
hi all i m having this "The resource cannot be found." error. I applied the url rewriting on my project every page is being browsed very well but i am getting the above error an some pages i dont know why? can any one suggest some solution. When i click on the button on that page i got this error with something like this "Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had...
0
8779
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8549
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7376
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6187
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5660
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4186
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4356
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2765
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2004
muto222
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.