Prevent backspace button from navigating back in Sharepoint 2010 and IE
Posted
by
Machinegon
on Stack Overflow
See other posts from Stack Overflow
or by Machinegon
Published on 2012-11-21T17:13:50Z
Indexed on
2012/11/23
17:05 UTC
Read the original article
Hit count: 211
as a user requirement I have to disable the backspace button from navigating back in the history. I made the following piece of code
//Bind back nutton to prevent escaping the page with backspace
$j(document).unbind('keydown').bind('keydown', function (event) {
var doPrevent = false;
if (event.keyCode === 8)
{
if(event.target == document.body){
if(event.preventDefault()){ event.preventDefault(); }
event.stopEvent();
event.returnValue = false;
}
}
});
This is working perfectly in all the browsers except IE8/7. I cannot bind the input types as exceptions because the content editor in sharepoint allows to modify the text in div or paragraph elements etc. The solution is not working in IE8 because the event.target returns the element that is on mouseover when there's no controls that has the focus.
All tips will be appreciated. Thanks!!
© Stack Overflow or respective owner