mardi 29 mars 2016

Disable broweser backspace in 3rd party iframe

I have a webpage serving a 3rd party iframe and its critical that once the users have landed on the page, they do not invoke browser back button when hitting backspace, without focusing on any text input fields. For that reason I have an override implemented as follows:

/* Disable backspace outside input fields */
$(document).keydown(function (e) {
    if (e.keyCode == 8 && e.target.tagName != 'INPUT' && e.target.tagName != 'TEXTAREA') {
        e.preventDefault ? e.preventDefault() : (e.returnValue = false);
    }
});

Unfortunately as this will only effect the content of the page itself, if the focus is on the iframe and the user's hit backspace my override does not kick in.

Please let me know if there is a way for me to ensure that the backspace override is implemented on the 3rd party iframe as well?

NOTE: Its not convenient to have 3rd party to make changes to their page that we are serving in iframe, and will be my last resort if I cannot find a solution.




Aucun commentaire:

Enregistrer un commentaire