0

This problem is well known that in IE for some crazy reason Backspace is used to go back your history navigation. In flex web applications sometimes this microsoft bug appears and it is a very bad headache to solve in a transparent and easy way.

Usually this problem occurs when you are editing text and textarea or textinput is inside TabNavigator container or you are editing text and textarea is inside a popup window.

Yury Euceda
  • 570
  • 4
  • 15
  • It's not just IE; Firefox does the same thing, at least on my system (Windows 7 64 bit) – Brian Apr 30 '15 at 20:48
  • Similar question: http://stackoverflow.com/questions/1495219/how-can-i-prevent-the-backspace-key-from-navigating-back?rq=1 – Brian Apr 30 '15 at 20:51
  • I don't understand why Brian you downrate my question if my only purpose is to share something I found. What I'm feeling is not to post anything here. If I post this is because I found it useful for me and I think I would be for others. – Yury Euceda Apr 30 '15 at 21:28
  • This is different than the question Brian references. Flex /Flash event handling is a different beast than pure JS. – Glenn Sep 15 '15 at 03:51

2 Answers2

2

I have a better answer to this problem. Yury's answer didn't help in my case. What did help was editing the adobe's history.js file:

Near the top of the file they check the useragent:

} else if (useragent.indexOf("msie") != -1 ) {
    browser.ie = true;
    browser.version = parseFloat(useragent.substring(useragent.indexOf('msie') + 4));

I noticed that it wasn't picking up Internet Explorer, since the useragent now says "mozilla" instead of msie.

} else if  (useragent.match(/msie|trident|edge/) ) {
        browser.ie = true;
       browser.version = useragent.indexOf('msie') < 0 ? 7 :  parseFloat(useragent.substring(useragent.indexOf('msie') + 4));

I'm just setting the version to be 7 if it matches trident or edge because this version of adobe's code only checks for 7 or less.

Glenn
  • 5,334
  • 4
  • 28
  • 31
1

Well, the solution is a combination of two jobs.

The first one is a javascript little change in your index.template.html file in your project (Flash Builder) or the ending html.

<script type="text/javascript">
    function init() {
        window.onkeydown = function(e) {
            var event = window.event || e;
            if(event.keyCode==8) {
                document.getElementById('${application}').focus();
                event.returnValue=false;
            }
        };
        setInitialFocus();      
    }

    function setInitialFocus() {
        document.getElementById('${application}').tabIndex = 0;
        document.getElementById('${application}').focus();
    }
</script>

<body onload="init()">

And the second one is a very little change in your project. You need to change to false a property called historyManagementEnabled in all TabNavigator components inside your project.

<mx:TabNavigator historyManagementEnabled="false">
</mx:TabNavigator>

Be aware on Accordion and ViewStack<---TabNavigator components because they implements IHistoryManagementClient as described http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/managers/IHistoryManagerClient.html

Yury Euceda
  • 570
  • 4
  • 15