如何在window.open中包含jquery函数
为了让打印预览“接受”样式,我需要在弹出窗口中包含一个用于打印的功能: 我用来打印的函数是:如何在window.open中包含jquery函数,jquery,telerik-grid,popupwindow,Jquery,Telerik Grid,Popupwindow,为了让打印预览“接受”样式,我需要在弹出窗口中包含一个用于打印的功能: 我用来打印的函数是: $('#printPersonnel').click(function () { var data = document.getElementById('personnelTable').outerHTML; var mywindow = window.open('', data); mywindow.document.write
$('#printPersonnel').click(function () {
var data = document.getElementById('personnelTable').outerHTML;
var mywindow = window.open('', data);
mywindow.document.write('<html><head><title>NORA Loading</title>');
mywindow.document.write('<link rel="stylesheet" type="text/css" href="http://localhost:49573/Content/Site.css">');
mywindow.document.write('<link rel="stylesheet" type="text/css" href="http://localhost:49573/Scripts/examples-offline.css">');
mywindow.document.write('<link rel="stylesheet" type="text/css" href="http://localhost:49573/Scripts/kendo.rtl.min.css">');
mywindow.document.write('<link rel="stylesheet" type="text/css" href="http://localhost:49573/Scripts/kendo.common.min.css">');
mywindow.document.write('<link rel="stylesheet" type="text/css" href="http://localhost:49573/Scripts/kendo.dataviz.default.min.css">');
mywindow.document.write('<link rel="stylesheet" type="text/css" href="http://localhost:49573/Scripts/kendo.dataviz.min.css">');
mywindow.document.write('<link rel="stylesheet" type="text/css" href="http://localhost:49573/Scripts/kendo.default.min.css">');
mywindow.document.write('</head><body>');
mywindow.document.write(data);
mywindow.document.write('</body></html>');
mywindow.document.close();
mywindow.focus();
mywindow.print();
mywindow.close();
return true;
});
您可以对结束脚本标记使用反斜杠
mywindow.document.write("<script>(function(){alert('1');})();<\/script>");
mywindow.document.write(((function(){alert('1');})(;));
您可以将
拆分为多个部分,因此它不会被解释为结束标记:
mywindow.document.write("<script>(function(){alert('1');})();" + "<" + "/script>");
mywindow.document.write(((function(){alert('1');})(;“+”);
能否提供包含
标签的代码?我无法解决这个问题。我可以使mywindow.document.write(((function(){alert('1');})())代码>工作,可能是问题出在$内。准备好了
函数体、语法错误还是什么?未终止的字符串常量
就是我的全部get@A.Wolff你说得对。编码
mywindow.document.write("<script>(function(){alert('1');})();" + "<" + "/script>");