admin管理员组文章数量:1277577
How can I remove prompt on unload event using javascript? thanks in advance...
hm, I don't want to show the prompt when firing the custom function for the unlaod event of the body... Is it possible? so here's my code:
window.onbeforeunload = function()
{
//cancel the unload
//cancel prompt
}
How can I remove prompt on unload event using javascript? thanks in advance...
hm, I don't want to show the prompt when firing the custom function for the unlaod event of the body... Is it possible? so here's my code:
window.onbeforeunload = function()
{
//cancel the unload
//cancel prompt
}
Share
Improve this question
edited May 18, 2011 at 8:56
kazinix
asked May 18, 2011 at 8:47
kazinixkazinix
30.1k36 gold badges111 silver badges162 bronze badges
1
- Please clarify your question. – ThiefMaster Commented May 18, 2011 at 8:49
2 Answers
Reset to default 9Make sure your event handler doesn't have a return
statement in it. Returning from the function triggers the conformation message.
Update based on the code ments in the edited question: If the user does something to leave the page, then you can tell the browser to ask them if they are sure. You cannot silently prevent them. If the user wishes to leave the page, then they can do so (dodgy sites full of adverts and/or malware would love it to be otherwise, thankfully it isn't)
Most certainly NOT impossible. All you have to do to suppress the prompt is omit the "return" statement. Returning any value will cause the prompt to fire. Example:
window.onbeforeunload = function saveAllData()
{
//Invoke AJAX method to save DataTable in database
[classname].SaveDataTable();
//return true; //ment out 'return' to suppress prompt
}
function SaveDataTable_Callback(response)
{
//alert(response);
}
本文标签: onbeforeunloadHow to remove prompt on unload event using javascriptStack Overflow
版权声明:本文标题:onbeforeunload - How to remove prompt on unload event using javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741213610a2359615.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论