简体   繁体   中英

Handle JS window onBeforeUnload Event in CRM 2011 Outlook-Client

I've got a problem to handle the window.onbeforeunload event in a JS-Application in a HTML-web resource for Microsoft Dynamics CRM 2011. By using the "normal" IE the following code works fine:

window.onbeforeunload = function (e) {
    if (changedData) {
        var message = 'leave...';
        if (typeof e == 'undefined') {
            e = document.parentWindow.event;
        }
        if (e) {
            e.returnValue = message;
        }
        return message;
    }
}

But in the CRM 2011 Outlook client, I don't get the leave message. Have you any idea to get a leave message when closing the window?

The CRM "object stack" in Outlook versus IE is likely to be different (since if nothing else, Outlook container windows are involved to wrap the IE Iframes) so when you are using "undocumented" events (in the CRM SDK sense) then you will be susceptible to such "surprises" ;)

What do you expect to happen with your code? You are only setting a returnValue on an event - this alone will not result in any user feedback.

Have you confirmed if your code is running at all (ie inserting an alert(); )?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM