views:

553

answers:

1

Hi,

I have this code block:

window.onbeforeunload = function(){
            <% if (Session["DisableExitConfirmation"] == null || !(bool)Session["DisableExitConfirmation"]) { %>
                if (isDirty) return '<%= Html.EncodeJsString(Html.Resource("profile_unsavedchanges")) %>';
            <% } else { %>
                if (isDirty) alert('<%= Html.EncodeJsString(Html.Resource("profile_unsavedchanges")) %>');
            <% } %>
        };

I am doing some DOM manipulation in the page, adding a LI element to a UL. I set isDitry to true when I am doing this and the window.onbeforeunload is raised when I am in Internet Explorer. I want it to be raised only when the user refreshes the page or quit it when isDirty is true.

In firefox I don't have this behavior.

I don't understand why this event is raised whend I do DOM manipulation with JQuery.

Does anyone know a workaround for this?

Thanks a lot,

Charles

A: 

Try this, "onUnLoad" should work for FF.

<body onunload="s();" onbeforeunload="s();">
pyccki