Disable backspace navigation on a page in the SalesLogix web client

I recently had to employ a way of preventing the backspace key from navigating back in the browser history on a page for a client.  I was able to do so by placing the following client side code onto the custom smart part:

//Adds removal of default backspace behavior to navigate away from a page.
$(function () {
    $(document).keydown(function (e) {
        var doPrevent;
        if (e.keyCode == 8) {
            var d = e.srcElement || e.target;

            if (d.tagName.toUpperCase() == ‘INPUT’ || d.tagName.toUpperCase() == ‘TEXTAREA’) {
                doPrevent = d.readOnly || d.disabled;
            }
            else
                doPrevent = true;

            if (doPrevent)
                e.preventDefault();
        }
    }
);
})

Normally this type of thing is not needed as the SLX master page has the “Dirty data” flag that will appear and warn a user they have unsaved chnages on the page before navigating away.  That was not suitable for my solution as the user was entering a large amount of data into an unbound form and needed to have a way of preventing the browser behavior.

This seems to work pretty good and was valid in both IE and FF.

ABOUT THE AUTHOR

Kris Halsrud

Kris Halsrud is a Senior Analyst / Developer for Customer FX Corporation.

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!

You have Successfully Subscribed!