意外结束字符串错误

时间:2018-01-29 20:01:12

标签: javascript

debugger; 
   // var header = '<html><head><title>Payment Details</title> <link href="../Content/bootstrap.min.css" rel="stylesheet" media="print" /> <link href="../Content/Kendostyle/kendo.common.min.css" rel="stylesheet"  media="print" />  <link href="../Content/Kendostyle/kendo.uniform.min.css"   media="print" rel="stylesheet" />  <link href="../Content/Site.css" rel="stylesheet" media="print"/> <link href="../Content/Menu.css" rel="stylesheet" media="print"/></head><body>';

    var header = '<html><head><title>Payment Details</title><link href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css\" rel=\"stylesheet\" media=\"All\" /> </head><body>';
    //var footer = '</body></html>';
    var w = window.open();
    var printstring = $("#printwrapper").html() + '</body></html>';
    w.document.write(header);
    w.document.write(printstring);
   // w.document.write(footer);
    w.document.close();
    w.focus();
    w.print();

1 个答案:

答案 0 :(得分:0)

下面:

var header = '<html><head><title>Payment Details</title><link href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css\" rel=\"stylesheet\" media=\"All\" /> </head><body>';

您正在使用反斜杠"转义引号\,但这不是必需的,因为您将字符串括在撇号'中。删除反斜杠\,如下所示:

var header = '<html><head><title>Payment Details</title><link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" media="All" /> </head><body>';

可能还有其他问题,但这至少是一个开始的地方。我没有在您的问题中包含的部分代码中看到其他错误。