<p>我正在尝试实现这样一个功能:如果弹出窗口打开并且用户取消它,然后按返回键,它不应该再次打开弹出窗口,而是应该返回到之前的页面!</p>
<p></p>
<pre class="brush:php;toolbar:false;"><script>
window.onload = function() {
setTimeout(function() {
window.open( "#popup_flight_travlDil3" ,"_self")
}, 1000);
}
</script></pre></p>
您可以使用sessionStorage
window.addEventListener("DOMContentLoaded", function() { // or $(function() { ... in jQuery const popped = sessionStorage.getItem("popped"); if (popped) return; setTimeout(function() { window.open("#popup_flight_travlDil3", "_self") sessionStorage.setItem("popped",true) }, 1000); })