onfocus在火狐、ie10浏览器失效解决方法方法

时间:2021-06-28 00:27:07

<script> 
    function setit(){ 
    if(document.all){ 
    document.getElementById("myframe").attachEvent("onfocus",dothis); 
    }else{ 
    document.getElementById("myframe").contentWindow.addEventListener("onfocus",dothis,false); 
    } 
    } 
    
function dothis(){ 
alert("blurred"); 

</script> 
<body onload="setit()"> 
<input /> 
</body>