javascript onpropertychange事件疑惑,上全部代码,请指教,为什么它会在IEx下自动执行呢?



 <!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src='jquery1.4.1.js'> </script>
</head>
<body>
    <script>    
    window.onload=function(){

        var ua=navigator.userAgent.toLowerCase();  
        var s=null;
        var form =document.getElementById('form1');
        var btn  =document.getElementById('inp1');
        var browser={    
          msie:(s=ua.match(/msie\s*([\d\.]+)/))?s[1]:false,    
          firefox:(s=ua.match(/firefox\/([\d\.]+)/))?s[1]:false,    
          chrome:(s=ua.match(/chrome\/([\d\.]+)/))?s[1]:false,    
          opera:(s=ua.match(/opera.([\d\.]+)/))?s[1]:false,    
          safari:(s=ua.match(/varsion\/([\d\.]+).*safari/))?s[1]:false    
        };   
        if(browser.msie)
        {//若为IE浏览器  

            btn.onpropertychange=function(){  
                 //do someting  
                 alert('IE成功111111')
            }  
        }  
        else{  

            btn.onchange=function(){  
                //do something
                   alert('成功')
            }  
        }  




    }

    </script>
    <input type='file' id='inp1'/>
    <form action='http://www.baidu.com' id='form1'>
        <input type='text'/>
        <input type='text'/>
        <input type='text'/>
    </form>
</body>
</html>

编程 程序员 css php JavaScript

威廉-伯爵 11 years, 8 months ago

Your Answer