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

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

WBOY
Release: 2016-06-06 20:46:49
Original
1108 people have browsed it

<code>


    <meta charset="UTF-8">
    <title>Document</title>
    <script src="jquery1.4.1.js"> </script>


    <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>


</code>
Copy after login
Copy after login

回复内容:

<code>


    <meta charset="UTF-8">
    <title>Document</title>
    <script src="jquery1.4.1.js"> </script>


    <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>


</code>
Copy after login
Copy after login
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template