问题
How to change the text of this function script?:
window.onbeforeunload = function(e) { return 'Are you sure you want to leave this page? You will lose any unsaved data.'; };
i want to translate the text " 'Are you sure you want to leave this page? You will lose any unsaved data.' " so it can say the same but in my language... how to do it? Please help - thanks
(when i translate it, it doesnt change in the frontend). Thanks in advance guys!
回答1:
unfortunately, changing the message seems to only work in Internet Explorer (see w3schools). I don't think you'll be able to insert blocking code either(such as alert()
), as it would be a security breach for the browser).
回答2:
also how to make the function be "on" for all external pages and be disabled for any inside pages like "domain.com -> domain.com/about-us" ?
来源:https://stackoverflow.com/questions/41812552/how-to-change-the-text-of-are-you-sure-you-want-to-leave-this-page-function-s