Firefox Web 浏览器中未显示确认消息

Confirmation message doesn't show up in firefox web browser

我正在使用我在互联网上找到的脚本,每当用户在更改后尝试离开页面而不提交表单时生成我的确认消息。

这是我的脚本:

<script type="text/javascript">
  var formSubmitting = false;
  var setFormSubmitting = function() { formSubmitting = true; };

    var _isDirty = false;
    var setDirtyField = function() { _isDirty = true; }
    window.onload = function() {
    window.addEventListener("beforeunload", function (e) {
        var confirmationMessage = 'Nepamirškite užpildyti užduoties žurnalo! ';
        //confirmationMessage += 'If you leave before saving, your changes will be lost.';

        if (formSubmitting || !_isDirty) {
            return undefined;
        }
        else{
            (e || window.event).returnValue = confirmationMessage; //Gecko + IE
            return confirmationMessage; //Gecko + Webkit, Safari, Chrome etc.  
        }

    });
};
</script>

这就是我在 google chrome 中使用此脚本看到的内容:

这就是我在 firefox 网络浏览器中看到的相同代码:

知道如何将我的文本添加到 firefox 确认消息吗?用我的替换现有文本将是完美的。

这是documented behaviour:

In Firefox 4 and later the returned string is not displayed to the user. Instead, Firefox displays the string "This page is asking you to confirm that you want to leave - data you have entered may not be saved." See bug 588292.

您无法覆盖默认文本。