SOSO用户的回答:javascript事件是会冒泡的,利用这个特性,你可以将这个两个事件绑定在最顶DOM层中 <script language="javascript">
document.documentElement.onkeydown=resetTime; document.doocumentElement.onclick=resetTime;
//增加上面黑体两句后,就不必在任何元素上onkeydown="resetTime()" onclick="resetTime()" 比如:<body onkeydown="resetTime()" onclick="resetTime()"> 就没必要了 <body>便可 SOSO用户的回答:javascript事件是会冒泡的,利用这个特性,你可以将这个两个事件绑定在最顶DOM层中 <script language="javascript">
document.documentElement.onkeydown=resetTime; document.doocumentElement.onclick=resetTime;
//增加上面黑体两句后,就不必在任何元素上onkeydown="resetTime()" onclick="resetTime()" 比如:<body onkeydown="resetTime()" onclick="resetTime()"> 就没必要了 <body>便可 刚SIR的回答:貌似 js脚本 没有session, 你可以window.load=resetTime() ; 只是这种写法容易出错,就用楼上师兄的就OK了 |