我有这样的代码:HTML写入新窗口中打开的问题
<div class="col3">
<a id = "training-launch-button" href="javascript:void(0);" title=" My title here" class="button" onClick="Test();">Launch</a>
</div>
function Test() {
var new_window= window.open('','Ratting','width=550,height=170,0,status=0,resizable=1');
new_window.document.createElement("div");
document.getElementsByTagName('div')[0].innerHTML = '<ol><li>html data</li></ol>';
}
东西是不正确的,我没有看到有序列表项? 我最终想在新窗口中构建一些HTML。
看看创建页面的来源 – CosminO
getElementsByTagName返回一个包含多个元素的数组,ocument.getElementsByTagName('div')[0] .innerHTML可能会更好。或者只使用id和getElementById。 – fijter
用chrome打开它并右击 - > inspectElement,检查错误并在这里粘贴相关错误请 – pythonian29033