javascript - 未捕获的 SyntaxError:尝试显示打印窗口时出现意外标识符
问题描述
尝试显示打印窗口时,我收到“未捕获的语法错误:意外的标识符”。它在本地运行良好,但是当我将它部署到 Ubuntu 服务器时,出现了错误。
function PrintDiv() {
var divToPrint = document.getElementById('divToPrint');
var site="<html lang='en'><body onload='window.print()'>" + divToPrint.innerHTML + "</html>";
var popupWindow = window.open('', '_blank', 'width=800,height=900');
popupWindow.document.write(site);
popupWindow.document.close();
}
我这样调用 div 来显示我正在打印的内容。
<div id="divToPrint" style="display:none;">
<div style="width:700px;height:900px;">
<h1 align="center">Active Accounts</h1>
<table border="1" align="center" width="100%">
<tr>
<th>Account ID</th>
<th>Name</th>
<th>Type</th>
<th>Phone</th>
<th>Address</th>
</tr>
<?php foreach($accounts as $account) : ?>
<tr>
<td><?php print $account->get_id(); ?></td>
<td><?php print $account->get_name(); ?></td>
<td><?php print $account->map_attribute_type(); ?></td>
<td><?php print $account->get_phone_number(); ?></td>
<td><?php print $account->get_address()->get_string(); ?></td>
</tr>
<?php endforeach; ?>
</table>
</div>
<input class="small button" type="button" value="print" onclick="PrintDiv();" />
解决方案
推荐阅读
- c - GoogleTest 在特定测试上强制 #undef
- python-3.x - Drop rows in dask dataFrame on condition
- reactjs - react-redux RangeError:超出最大调用堆栈大小
- pine-script - 如何在 tradingview pine 编辑器中获取第二个 15m 蜡烛的范围?
- css - 如何解决 CSS 元素之间的冲突?
- python - python boto3 如何在镶木地板上配置 AWS s3select?
- node.js - CredentialsError:配置中缺少凭据。在 EC2 中使用 S3 SDK 时
- api - 我如何告诉 Gitlab 通过 API 镜像我的 Github 存储库?
- ballerina - 芭蕾舞女演员:外来输入“S”期待{
, '','','',''} 使用 ballerina/config 读取配置时出现错误 - python - 遍历 pandas 数据帧,同时保留早期状态的内存