每当用户尝试离开页面而不提交更改后的表单时,我正在使用在互联网上找到的脚本来生成确认消息。
这是我的脚本:
<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>
这就是我在 Firefox Web 浏览器中使用相同代码看到的结果:
知道如何将我的文本添加到 Firefox 确认消息中吗?用我的替换现有文本将是完美的。
最佳答案
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.
您无法覆盖默认文本。
关于javascript - Firefox 网络浏览器中不显示确认消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31717041/