Javascript 确认导航不显示我的信息
我用过这个,但它没有显示我的自定义消息,而是显示它自己的消息Javascript 确认导航不显示我的信息,javascript,dom,Javascript,Dom,我用过这个,但它没有显示我的自定义消息,而是显示它自己的消息 <script language="JavaScript"> var needToConfirm = true; window.onbeforeunload = confirmExit; function confirmExit() { if (needToConfirm) return "You have attempted to leave this page. If you
<script language="JavaScript">
var needToConfirm = true;
window.onbeforeunload = confirmExit;
function confirmExit()
{
if (needToConfirm)
return "You have attempted to leave this page. If you have made any changes to the fields without clicking the Save button, your changes will be lost. Are you sure you want to exit this page?";
}
</script>
var needToConfirm=true;
window.onbeforeunload=确认退出;
函数confirmExit()
{
如果(需要确认)
return“您试图离开此页面。如果您在未单击“保存”按钮的情况下对字段进行了任何更改,您所做的更改将丢失。是否确实要退出此页面?”;
}
自定义消息将仅在Google chrome中显示,Firefox目前不支持该消息。尝试使用alert而不是return