尝试显示打印窗口时,出现“ Uncaught 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();" />