0
我试图在页面中获取元素的innerHtml,但innerHtml总是返回undefined。我已经测试了getElementById,没关系,该方法实际上可以找到我想从中获取html的表单元素。getElementById(element).innerHtml返回undefined
JavaScript函数将通过一个按钮来调用,它会打开一个新的窗口形式的内容:
function Popup(data){
var formElement = document.getElementById(data);
var content = formElement.innerHtml;
var mywindow = window.open('', 'my div', 'height=400,width=600');
mywindow.document.write('<html><head><title>Checklist</title>');
mywindow.document.write('</head><body >');
mywindow.document.write(content);
mywindow.document.write('</body></html>');
mywindow.print();
mywindow.close();
return true;
}
我已检查formElement变量的值,它是:对象HTMLFormElement。
多么愚蠢的错误,非常感谢,我是Javascript的新手,并没有注意到之前。 – 2014-09-06 16:30:29