onfocus事件火狐和IE不兼容!好像最新版的ff已经解决了这个问题!

解决方案 »

  1.   

    关键是有没有实现onfocus的变通的办法?
      

  2.   

    <iframe style="border:1px solid #CC99FF" id="WEditor" name="WEditor" height="200" width="397" marginheight="2" marginwidth="2"></iframe>
    <script>
    var isIE = document.all;
    var isFF = window.getSelection;
    if (isIE)//IE
    {
        editor.onfocus = function(){alert("a");}
    }
    else if (isFF)//FireFox
    {
            //这里麻烦大大们补一下下
    }
    </script>
      

  3.   

    少了一句 var editor = document.getElementById("WEditor").contentWindow; 
      

  4.   

    ff下的iframe没有onfucus事件如果你是做编辑器,可以对iframe中的document添加onclick事件,并且绑定事件时不能使用document.onclick=function(){代码}只能使用document.addEventListener来绑定
      

  5.   

    <iframe style="border:1px solid #CC99FF" id="WEditor" name="WEditor" height="200" width="397" marginheight="2" marginwidth="2" onfocus="alert('a')" > </iframe> 
    <script> 
    var isIE = document.all; 
    var isFF = window.getSelection; 
    window.onload=function()
    {
    var editor=isIE?document.getElementById("WEditor"):document.getElementById("WEditor").contentWindow
    if (isFF)//FireFox 

       editor.document.addEventListener("click",function(){alert("a");},false);

    }
    </script>