Mozilla firefox not working with [removed]

前端 未结 4 646
清酒与你
清酒与你 2020-11-30 11:35

I\'m using window.onbeforeunload to display a message to the user on windows close, the function works well with Chrome and IE but it doesn\'t work with Firefox

4条回答
  •  Happy的楠姐
    2020-11-30 12:16

    Why are you doing browser-sniffing here? The "Firefox" branch of your code is returning the return value of window.confirm, which is a boolean. But a boolean isn't callable, so assigning it to window.onbeforeunload is the same as assigning null.

    What you probably want to do is remove the browser-sniffing and just do:

    window.onbeforeunload = confirmExamClose;
    

提交回复
热议问题