0

在我的代码中,我为弹出窗口编写了此代码,但注释行

// mywindow.document.write('<html><head><title>my div</title>');

自动执行。为什么?如果我删除了这一行,我的页面不会显示任何错误。如果它作为注释出现,则显示重复标题标签的错误。

 function Popup(data) {
            var mywindow = window.open('', 'mydiv', 'height=400,width=600');
           // mywindow.document.write('<html><head><title>my div</title>');
            /*optional stylesheet*/ //mywindow.document.write('<link rel="stylesheet" href="main.css" type="text/css" />');
            mywindow.document.write('</head><body >');
            mywindow.document.write(data);
            mywindow.document.write('</body></html>');
            mywindow.document.close();
            mywindow.print();
            return true;
        }
4

1 回答 1

2

如果您在服务器上执行它然后对其进行注释,则服务器可能已经缓存了您的旧 js 文件...尝试将参数(任何)传递给标记中的 js 文件:<script src="myfile.js?version=1.0"/>

于 2012-05-15T12:20:14.900 回答