我正在开发一个页面,需要用自定义文本显示确认信息。这是我的代码,它工作正常,但它没有显示我的消息。浏览器显示默认消息,但我不知道为什么。
function unloadPage(){
confirm(" i can't see this message");
// same result when i try with : return "i can't see this message";
}
window.onbeforeunload = unloadPage;
谁能解释一下如何强制浏览器接受我的自定义确认消息,并忽略默认的浏览器消息?
最佳答案
在页面加载时,您应该使用onload
方法。
window.onload = unloadPage();
function unloadPage()
{
return confirm(" i can see this message");
}
关于javascript - 如何在页面加载时显示自定义消息确认?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46325439/