无法将日期从Javascript传递到HTML页面
因此,我试图将我的日期从无法将日期从Javascript传递到HTML页面,javascript,date,footer,hierarchy,Javascript,Date,Footer,Hierarchy,因此,我试图将我的日期从JS文件中的函数传递到我的html网页中。出于某种原因,我一直得到这样的错误 /* 异常:无法在层次结构中的指定点插入节点 @42 */ 非常感谢您的帮助。这是我的密码 function time() { //function to add date/time stamp to the footer of the html document var timestamp=document.getElementById("time"); var timec
JS
文件中的函数传递到我的html
网页中。出于某种原因,我一直得到这样的错误
/*
异常:无法在层次结构中的指定点插入节点
@42
*/
非常感谢您的帮助。这是我的密码
function time() { //function to add date/time stamp to the footer of the html document
var timestamp=document.getElementById("time");
var timecreation=document.createTextNode("p");
var d = new Date();
var timetextnode=document.createTextNode(d);
timecreation.appendChild(timetextnode);
timestamp.appendChild(timecreation);
}
time();
以及HTML
<hr size="2" width="100%">
<footer id = "time">
<p> Michael Longo web site, July 2013 </p>
</footer>
应该是
var timecreation=document.createElement("p");
不能附加到文本节点
var timecreation=document.createElement("p");