M
Mike Duffy
1) I have successfully done this sort of thing before. I have re-checked
my capitalization, and looked at my other code that works. Then I removed
everything except what is needed to reproduce the error. I have even r-
typed the line with the div element to preclude unprintable characters,
and checked that the whole file is okay with the w3 validator service. (
http://validator.w3.org/ )
When the page is loaded, and function testFunc() is evaluated, it tells
me that the div element is null. I would appreciate it if someone can
tell me what I have neglected.
To save anyone from typing, I have placed a copy of the html source at:
http://pages.videotron.com/duffym/test_01.htm
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Test</title>
<script type="text/javascript">
function testFunc()
{
alert('The element itself: '+document.getElementById("test"));
alert('The text in the div tag: '+document.getElementById
("test").innerHTML);
}
</script>
</head>
<body>
<p>Dummy text that is outside the div element.</p>
<script type="text/javascript">testFunc();</script>
<div id="test"><p>Dummy text that is in the div.</p></div>
</body>
</html>
my capitalization, and looked at my other code that works. Then I removed
everything except what is needed to reproduce the error. I have even r-
typed the line with the div element to preclude unprintable characters,
and checked that the whole file is okay with the w3 validator service. (
http://validator.w3.org/ )
When the page is loaded, and function testFunc() is evaluated, it tells
me that the div element is null. I would appreciate it if someone can
tell me what I have neglected.
To save anyone from typing, I have placed a copy of the html source at:
http://pages.videotron.com/duffym/test_01.htm
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Test</title>
<script type="text/javascript">
function testFunc()
{
alert('The element itself: '+document.getElementById("test"));
alert('The text in the div tag: '+document.getElementById
("test").innerHTML);
}
</script>
</head>
<body>
<p>Dummy text that is outside the div element.</p>
<script type="text/javascript">testFunc();</script>
<div id="test"><p>Dummy text that is in the div.</p></div>
</body>
</html>