window.onbeforeunload = function(){ return confirm('是否离开此页面'); } 转载于:https://www.cnblogs.com/lixingbaophp/p/5916494.html