我正在用asp.net开发web应用程序。我的要求是在每个按钮点击事件上显示确认消息,比如(插入、更新和删除按钮)。我使用jQuery消息框在整个应用程序中成功地插入、更新和删除。
function MessageBox(Title, InnerText) {
try {
var dialog = $('<p class="messagebox">' + InnerText + '</p>').dialog({
title: Title,
width: "240",
modal: true,
buttons: {
"OK": function () {
dialog.dialog('close');
}
}
});
}
catch (e) {
MessageBox('Tracker Alert', e);
}
}
按钮单击事件上的呼叫
Result = Save_UpdateData(2);
if (Result > 0)
{
ScriptManager.RegisterStartupScript(this, GetType(), "msg", "MessageBox('Tracker Alert', 'Record updated succesfully');", true);
}
那么,如何使用类似于上述功能的jQuery消息框在按钮点击事件上显示确认消息?
发布于 2015-10-03 14:55:47
<script type="text/javascript">
$(window).on('mouseover', (function () {
window.onbeforeunload = ConfirmLeave;
}));
$(window).on('mouseout', (function () {
window.onbeforeunload = ConfirmLeave;
}));
function ConfirmLeave() {
return "";
}
var prevKey = "";
$(document).keydown(function (e) {
if (e.key == "F5") {
window.onbeforeunload = ConfirmLeave;
}
else if (e.key.toUpperCase() == "W" && prevKey == "CONTROL") {
window.onbeforeunload = ConfirmLeave;
}
else if (e.key.toUpperCase() == "R" && prevKey == "CONTROL") {
window.onbeforeunload = ConfirmLeave;
}
else if (e.key.toUpperCase() == "F4" && (prevKey == "ALT" || prevKey == "CONTROL")) {
window.onbeforeunload = ConfirmLeave;
}
prevKey = e.key.toUpperCase();
});
</script>
https://stackoverflow.com/questions/32919738
复制相似问题