js代码:
1 <script type="text/javascript"> 2 let clickNotes = 0; 3 let timeover = null; 4 function back() { 5 clickNotes++; 6 if (timeover) clearTimeout(timeover); 7 8 timeover = setTimeout(() => { 9 if (clickNotes == 1) { 10 // do something 点击一次触发 11 console.log(-1); 12 window.history.go(-1); 13 } else { 14 // do something 点击两次触发 15 console.log('关闭'); 16 window.close(); 17 } 18 timeover = null; 19 clickNotes = 0; 20 }, 1000); 21 } 22 </script>