2016-10-19 17 views
0

で作業していないインラインフレーム本体上のイベントをぼかし:は、フォーカスを設定すると、私のように編集可能なiFrameを作成しているFirefoxの

<iframe frameborder="0" id="editor"></iframe> 

<script type="text/JavaScript"> 
    document.getElementById('editor').contentWindow.document.designMode="on";          
    document.getElementById('editor').contentWindow.document.close(); 

    $("#editor").contents().find("body").blur(function(){ // Blur functions }); 

    $("#editor").contents().find("body").focus(function(){// focus functions }); 

</script> 

フォーカスとブラーイベントクロームでトリガが、Firefoxのために働いていない得ています。それはボディのために)内容(上の設定したフォーカス/ぼやけていない作品Firefox用

<iframe frameborder="0" id="editor"></iframe> 

<script type="text/JavaScript"> 
    document.getElementById('editor').contentWindow.document.designMode="on";          
    document.getElementById('editor').contentWindow.document.close(); 

if(navigator.userAgent.indexOf("Firefox") != -1){ 
    $("#editor").contents().bind('blur', function(){ // Blur functions }); 
    $("#editor").contents().bind('focus', function(){ // focus functions }); 
}else{ 
    $("#editor").contents().find("body").blur(function(){ // Blur functions }); 
    $("#editor").contents().find("body").focus(function(){ // focus functions }); 
} 
</script> 

:として解決

答えて

0

+0

残念ながら、残念ながら、このようなぼかし/フォーカスの機能の前に警告を出した場合にのみ、firefoxのコードは機能しません。 'if(navigator.userAgent.indexOf(" Firefox ")!​​= -1 ){ アラート( "Firefox"); $ {"#editor"}。コンテンツ()。bind( 'blur'、function(){// Blur functions}); ( 'focus'、function(){// focus functions}); //( "#editor")。 } ' – Craz1k0ek

関連する問題