Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在window.open中包含jquery函数_Jquery_Telerik Grid_Popupwindow - Fatal编程技术网

如何在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>");