我继承了以下代码:
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<!--<meta http-equiv="refresh" content="1" />-->
<link href="../static/css/style.css"
th:href="@{css/style.css}" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="container">
<div class="jumbotron">
<h3 style="color:yellow;">
BAD/WARNING
</h3>
<h3>
APPLICATION PROCESSING MONITORING
</h3>
<table id="tablePmBad">
<tr>
<th> Status </th>
<th> HostName </th>
<th> Process Name </th>
<th> Process Count </th>
</tr>
<tr>
<td> BAD </td>
<td> Host1 </td>
<td> process1</td>
<td> 0 </td>
</tr>
</table>
<h3 style="color:green;">
GREEN/NORMAL
</h3>
<h3>
APPLICATION SERVER
</h3>
<table id="tablePmGreen">
<tr>
<th> Status </th>
<th> Host </th>
<th> Cpu Memory </th>
<th> App Memory </th>
<th> Opt Memory </th>
</tr>
<tr th:each="datamem", iterStat : ${datalist}">
<td th: "${datamem.status}"></td>
<td th: "${datamem.host}"></td>
<td th: "${datamem.cpuMem}"></td>
<td th: "${datamem.appMem}"></td>
<td th: "${datamem.optMem}"></td>
</tr>
</table>
<h3>
MONITORING
</h3>
<table id="tableMGreen">
<tr>
<th> Status </th>
<th> HostName </th>
<th> Process Name </th>
<th> Process Count </th>
</tr>
<tr th:each="data, iterStat : ${countlist}">
<td th: "${data.Status}"> </td>
<td th: "${data.host}"> </td>
<td th: "${data.pName}"></td>
<td th: "${data.pcount}"></td>
</tr>
</table>
<script src="../static/css/color.js" type="text/javascript" th:src="@{css/color.js}"></script>
</div>
</div>
</body>
</html>
// if parent window is closed or changed, close popups
window.onbeforeunload = function () { /* some cleanup stuff */ };
window.onchange = function () { /* same exact cleanup stuff */ };
行导致问题;
在Chrome上,它没有明显的原因(具有不良清理结果)。它不会在IE11中触发。
我能安全地摆脱这条线吗?
Mozilla guys不会提供太多信息:
发送到窗口的更改事件的事件处理程序。
......和互联网一般似乎没什么可说的。
那究竟是什么触发window.onchange
?它适用于所有主流浏览器吗? (如果没有,那么对我来说这是一个足够好的保证我可以删除它。)
答案 0 :(得分:1)
更改表单控件时更改事件。在下面的演示中,键入内容,然后点击 Tab 以模糊控件并触发更改事件。
onchange = function (e) { console.log(e.target); }
<input>
事件冒泡,因此侦听器不需要直接连接到输入。
在你的例子中,不可能说“删除”是否“安全”,因为没有提供关于清理内容的上下文,因此我们无法判断执行清理是否有必要/有用/有害在每次变革事件之后。