質問

Ok、私がこの問題は、こういった

  1. いただいたAJAX呼びIE7います。onbeforeunload機能を指定された通話のonbeforeunloadます。

  2. の場合を開いてみては新しいウィンドウウインドウです。開を乱すことなく現在のウィンドウのonbeforeunloadが呼び出されます。

なんだろうけど、日本人に歯止めをかけよう。もし設定の変数をTRUEにカットすることに変私のonbeforeunload機能だけでは主にチーム戦!いる必要があり停止をすることができるの執行が法AJAX通話および新しいウィンドウます。

役に立ちましたか?

解決

もう一つ、おそらく単純なオプションでは、ポップアップを開いたときにfalseを返すことです。

<a onclick="window.open(...); return false;" href="javascript:;" >my link</a>

このは、ページを残している思考やイベントをトリガからIEを停止しているようです。他のすべてのオプションは私のために特に実行可能ではなかった。

他のヒント

OK、私はこの問題を抱えています。私はそれのために回避(かなり汚い)を持っています。

私の場合、私は他の人を離れ、時にはナビゲーションをブロックしたい、とないます。

だから、私はそれがブロックされたい場合は私に教えて、ウィンドウの上にフラグを設定しています。だからここであなただけの、その前に、あなたのwindow.openを行っている、 'window.allowExit = true' を、その後onbeforeunloadに、真のwindow.allowExit =のためにチェックします。

私は、Javaスクリプト(のShowHelp)は、リンクからキックオフされています

<a href="javascript:ShowHelp('argument')" >HERE</a>

はonbeforeunloadのShowHelp前に呼び出され、私は、フラグを設定するためのonclick使用される

<a onclick="window.allowExit = true;" href="javascript:ShowHelp('argument')" >HERE</a>

罪として醜いが、動作しているようです!

このことが解決とはならないが、説明のための人が興味がありました。私た試IE7ので火災のonebeforeunloadイベント間にリンクをクリックしない限り、URLがどこかに同じページ:すなわちない限り、含#.このような中、私の推測では、IEエンジニアを考えることがあり、クリックリンクをはることはないか、そのページにしなければならなく、そのページのページではアンロード.言うまでもなく、明らかな問題にこの考え方です。

私はあなたがちょうどあなたが何かをして、完了したら、それを戻す前に、window.onbeforeunload機能の設定を解除する必要があることを考え出します。

私はIEで機能を無効に終わっています。

私は、標準のボタンでporblemを固定したときに、私は私の集中管理機能にonclickのすべてをリダイレクトするように再帰関数をしたので、

私は同じ問題が、私の場合には、すべての要求がAJAX呼び出しから来ていた、これは、ソリューションを簡素化し、その後dispath rigthクリックしてください。 私もhrefの問題をsuporting AJAX呼び出しのためのソリューションをコピーしています。 このソリューションは、前のページに戻るには避けてください。 JS、という名前のファイル戻るボタン内のコードを入れてください 対象とmparma@usa.netするために、任意のコメント書き込み:javascriptの戻るボタン

<!--  backbutton developed by Manuel Parma 2011-06-10 -->
<!--  email: mparma@usa.net -->
<!--  Add the next line into the <body> section as a first line  -->
<!--  <script type="text/javascript" src="<path>/backbutton.js"></script> -->

<!-- Address used when backtoLogin is 1 or when there is not previous page from site -->
var returningAddress = "http://my returning address"

<!-- Message to display when an external action (back button, forward button, backspace) move without press the application buttons -->
var backButtonMessage = "Using the browser's Back button may cause a loss in data. Please use the Back and Continue buttons at the bottom of the form."

<!-- 0=no / 1=yes (assume per default that the back button will be pressed -->
<!--               and come into action if this was NOT the case)          -->
var backButtonPressed = 1;    

<!--This var when is setted to 1 avoid to captureEvent set backbuttonPressed to 1, otherwise unload event cannot detect the right state of backButtonPressed-->
var onbeforeunloadeventFired = 0;

<!--Indicate to logic back to first page (login) when its value is 1 otherwise the logic back to previous page out of the site-->
var backtoLogin = 0;
var DoPostBackWithOptionsHook = null;
var DoPostBackHook = null;


<!-- Check the previous status -->
if (window.name == ""){
    <!-- When window.name is empty, this is indicating the first call of site -->
    window.name = "L0001";
}
else { 
    if (window.name == "L0000_back"){
        <!-- In this condition the page is returning after a foward button press  -->
        setBackButton(0);
        window.name = "";

        <!-- the system reload the page to clean the data -->
        window.location.href = returningAddress;
    }
    else {
        if (window.name.indexOf("_back") > 4){
            <!-- when the word back is present, the previous call is sending a message that the back button was pressed and the site is going out -->

            <!-- get the internal counter -->
            var sLastValue = modifynamevalue(0);    

            <!-- set the count to go back -->
            var iCountBack = -(sLastValue * 1);
            if (backtoLogin == 1) {iCountBack++;};

            if (window.history.length - 2 < -iCountBack) {
                iCountBack = -(window.history.length - 2);
            }

            <!-- the site is flag that first page needs to reload -->
            window.name = "L0000_back";             
            setBackButton(0);

            <!-- the site is returning to the first page or previous -->
            window.history.go(iCountBack);
        }
        else {
            <!-- increase the internal counter -->
            var sLastValue = modifynamevalue(+1);
            window.name = "L" + sLastValue;
        }
    }
}

<!-- Set the events needed to manage the back and forwar button situations -->

$(document).ready(function(){
    if (typeof(Sys) == "object") {
        Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginRequest);
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequest);

        window.onbeforeunload = onbeforeunloadEvent;
        window.onunload = unloadEvent;
        DoPostBackWithOptionsHook = WebForm_DoPostBackWithOptions;
        WebForm_DoPostBackWithOptions = WebForm_DoPostBackWithOptionsHook;

        doPostBackHook = __doPostBack;
        __doPostBack =  __doPostBackHook;

    }

    });

function WebForm_DoPostBackWithOptionsHook(options) {
    setBackButton(0);
    return DoPostBackWithOptionsHook(options)
}

function __doPostBackHook(eventTarget, eventArgument) {
    if (backButtonPressed == 1) {
        setBackButton(0);
    }
    return doPostBackHook(eventTarget, eventArgument)
} 

function beginRequest(sender, args) {
    setBackButton(0);
    <!-- setting onbeforeunloadeventFired = 1 I take care to avoid anyone changed the Backbutton until endrequest -->
    onbeforeunloadeventFired = 1;
}


function endRequest(sender, args) {
    onbeforeunloadeventFired = 0;
    setBackButton(1);
}

<!-- unload event handler -->
function unloadEvent(evt) {
    <!-- double coundition using onbeforeunloadeventFired == 1 garantee avoid problemas with redirect operations -->
    if ((backButtonPressed == 1) && (onbeforeunloadeventFired == 1)) {
        <!-- decrement the internal counter -->
        var sLastValue = modifynamevalue(-1);
        window.name = "L" + sLastValue + "_back";
    }

    if (DoPostBackWithOptionsHook !== null) {
        WebForm_DoPostBackWithOptions = DoPostBackWithOptionsHook;
    };

    if (doPostBackHook !== null) {
        __doPostBack = doPostBackHook;
    };
}

<!-- on before unload -->
function onbeforeunloadEvent(evt) {
    onbeforeunloadeventFired = 1;
    if (backButtonPressed == 1) {
        return backButtonMessage;
    };
}


<!-- used to set right backButtonPressed-->
function setBackButton(value){
    if (value == 0) {
        backButtonPressed = 0;
    }
    else {
        if (onbeforeunloadeventFired == 0) {
            backButtonPressed = 1;
        }
    }
}


<!-- increment and decrment the internal counter stored into windows.name -->
function modifynamevalue(iIncrement){
    var iCount = (window.name.substring(1, 5) * 1) + iIncrement;

    if (iCount < 0) {
        iCount = 0;
    }

    var sNewValue = iCount.toString();

    sNewValue = "0000".substring(0, 4 - sNewValue.length) + sNewValue;
    return sNewValue;
}

Sid_Mは、ブラウザのデザインで、我々はそれに応じて私たちのアプリケーションを設計する必要があり、有効なポイントを語っています。

なぜ、ラベル、あるいはTDタグにonclickの方法を使用し、ポップアップウィンドウのためのアンカータグのhref&ために行くとwindow.open

コールします

私のアプリケーションのいずれかから、簡単な例

<td class="popuplink" onMouseOver="this.style.cursor='hand'" onclick="javascript:openMe('img/howitworks.png', 'pndpopup', 600,650)"><u> How it works</u></td>

あなたはwindow.openのために呼び出す前に「onbeforeunload」イベントからハンドラを削除しようとしたのですか?これは助けることができますが、私はそれをテストしたことはありません。

これは非常に可能性があなたの問題を解決することができます!

私は同様の問題を持っていたし、これは行く道を作ったので!

window.onbeforeunload = warnFunction;
var warnRequired = true;
function warnFunction () {
    if (warnRequired) return ("Please Stay! Don't go!");
    return ;
}

そして、私はAjax呼び出しまたはポップアップ別のウィンドウを行うたびに、私はちょうどfalseに設定warnRequiredます。

Ajax呼び出しを行うときに

もうひとつはちょうど変数がまだ設定されていない可能性があります他に同期していることに注意してください! (厄介なガッチャ!)

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top