Monthly Archives: December 2015

Disable Escape in Xpinc

Hey All

I found this little piece of code a while ago, that I use for every Xpinc app I am working on.

Just thought I would re share it because I find it invaluable.  Without it your users will have a tendency to just hit Escape which will close the app and could lose all their changes.

Special thanks to Tommy Valand for sharing it.

http://dontpanic82.blogspot.ca/2010/08/xpinc-prevent-tabs-being-closed-on-esc.html

The only thing I add is an alert to tell my users to save.

Add code to Event=>OnClientLoad=>CSJS

dojo.addOnLoad( function(){
dojo.connect( document, ‘keydown’, function(e){
// 27 -> Key code for ESC -> stop event
if(e.keyCode === 27){
dojo.stopEvent(e);
alert(“Escape has been disabled, Please save and then close the Tab”);
}
});
});

Enjoy

JT