可能在页面重新加载时触发JavaScript功能?
答
您的意思是确认一个“卸载”,从而在用户离开当前页面之前执行一个功能。
<html>
<head>
<script type="text/javascript">
function mymessage()
{
//this is the sample function code executed on "unload"
alert("This message was triggered from the onunload event")
}
</script>
</head>
<body onunload="mymessage()">
<p>close this window</p>
</body>
</html>
OR
jQuery的版本http://api.jquery.com/unload/
答
难以推断究竟你想,但你在你想要的页面被刷新,你可以前一个函数来执行的意见陈述使用unload
$(window).unload(function() {
alert('Handler for .unload() called.');
});
这是什么意思?您想做什么?你的意思是*调用JavaScript函数吗? – 2012-01-01 09:55:12
澄清请问?写在重新加载的JavaScript?那是什么意思? dymnamically写JS?或者你的意思是使用JS – Joseph 2012-01-01 09:55:47
@fskreuz重新加载页面:不,当用户单击浏览器中的重新加载标签时,我想在执行之前执行一个函数,然后重新加载当前页面 – 2012-01-01 09:59:48