In neither case does this page display correctly: the "hello world" is supposed to display after whatver is dynamically loaded in the div tag as it precedes the paragraph tag containing the "hello world" text.
I don't remember having this problem before with dhtml. How is it done correctly?
test.js
test.html
I don't remember having this problem before with dhtml. How is it done correctly?
test.js
Code:
function test1()
{
var display = document.getElementById("display");
display.innerHTML = "This should display before 'hello world', but replaces it instead.";
}
function test2()
{
var display = document.getElementById("display");
var text_node = document.createTextNode("This should display before 'hello world', but appears AFTER it instead.");
display.appendChild(text_node);
}
test.html
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<title></title>
<script type="text/javascript" src="test.js"></script>
</head>
<body>
<div>
<input type="button" onclick="test1();" value="click" />
<input type="button" onclick="test2();" value="click" />
<div id="display" />
<p>hello world</p>
</div>
</body>
</html>