ポストバックでいくつかの機能が実行されていますが、完了まで少し時間がかかります。ポストバックの前にユーザを止める(JavaScript/ASP.NET)
ポストバックが開始されると、私はこのコードの読み込み画像を表示:
function showLoader()
{
document.getElementById("<%=loadingImage.ClientID%>").style.visibility="visible";
}
私は、ユーザーが、この時点で残すことをしようとする場合、彼らは操作が通知されるように、この関数にコードを追加できるようにしたいです完了しません。
私はこのコードを見つけました:
function goodbye(e) {
if(!e) e = window.event;
//e.cancelBubble is supported by IE - this will kill the bubbling process.
e.cancelBubble = true;
e.returnValue = 'You sure you want to leave?'; //This is displayed on the dialog
//e.stopPropagation works in Firefox.
if (e.stopPropagation) {
e.stopPropagation();
e.preventDefault();
}
}
window.onbeforeunload=goodbye;
これは動作しますが、ロードイメージがアクティブなとき、私はコードのみがアクティブになりたいです。
私は次のことを試してみましたが、バックのページ最終的に投稿するときには、警告メッセージが表示されます。
function goodbye(e) {
if(!e) e = window.event;
//e.cancelBubble is supported by IE - this will kill the bubbling process.
e.cancelBubble = true;
e.returnValue = 'You sure you want to leave?'; //This is displayed on the dialog
//e.stopPropagation works in Firefox.
if (e.stopPropagation) {
e.stopPropagation();
e.preventDefault();
}
}
function showLoader()
{
document.getElementById("<%=loadingImage.ClientID%>").style.visibility="visible";
window.onbeforeunload=goodbye;
}
私はちょうどこれを微調整することができますどのように任意のアイデアは、ポストバックが完了したときに、ユーザーがページを離れていないときに表示?