Backspace issue in Flex Application on IE 8 and IE

2019-09-06 18:15发布

问题:

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.

回答1:

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.



回答2:

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