$(document).ready(function() { window.onbeforeunload = function() { try { return "确认放弃吗?"; } catch (e) { } } });