我有这个代码......它在Google Chrome上工作正常,但是Firefox和EI以及Safari一直在反复播放警报。我应该添加什么来确保警报只进行一次。
<html>
<script language="JavaScript">
<!--
document.onclick = myClickHandler;
function myClickHandler() {
alert("All orders require minimum two weeks notice before your event");
}
-->
$(function() {
$(document).on('click.once', function() {
alert("Thank you for your visit. Happy shopping!!");
$(document).off('click.once');
})
});
</script>
</html>
答案 0 :(得分:1)
$(function() {
$(document).on('click', function() {
alert("Thank you for your visit. Happy shopping!!");
$(document).unbind('click');
})
});