2010-06-04 4 views
2

이 IE에서 작동하지만, 파이어 폭스에서 매우 이상하다 :iframe이 대해 designMode

정상적으로를 열면 파이어 폭스의 대해 designMode가 작동하지 않는 경우,하지만 난

에 중단 점을 넣어 경우 this.editor.contentWindow.document.designMode = "설정";

라인을 입력 한 다음 해제 한 다음에는 해제 한 후 디자인 모드가 작동합니다.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
<html> 
    <head> 
     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
     <title>Untitled Document</title> 
     <script type="text/javascript"> 



TheEditor = function() { 
    this.editor = null; 
    this.mainDiv=document.getElementById("mainDiv"); 
} 

TheEditor.prototype = { 

     InitializeEditor: function() { 


     this.editor=document.createElement('iframe'); 
     this.editor.frameBorder=1; 
     this.editor.width = "500px"; 
     this.editor.height="250px";  

     this.mainDiv.appendChild(this.editor); 

     this.editor.contentWindow.document.designMode = "On";  
    }  


} 
      window.onload = function(){ 
       obj = new TheEditor; 
       obj. InitializeEditor(); 
      } 
     </script> 
    </head> 
    <body> 
     <div id="mainDiv"> 
    </div> 
    </body> 
</html> 

답변

0

나는 모든 이유를 이해하지 않지만, 개방 (선택적으로 작성 내용) 및 문서를 닫으면 (OSX에 적어도 FF5에서) 문제를 해결 :

this.editor.contentWindow.document.open(); 
// optionally write content here 
this.editor.contentWindow.document.close(); 
this.editor.contentWindow.document.designMode = "on"; 

내가 가진 다른 생각을 designMode = "on" 진술 (나는 FF로 이것을하기 위해해야만했던 것을 기억한다) 주위에 타임 아웃을 설정하는 것이었다. 그러나 그것은 작동하지 않았다.

IFRAME에 FF가로드되어 있고 designMode를 켤 준비가되지 않았다고 생각합니다.

DIV 대신 contentEditable="true" 속성을 사용할 수도 있습니다.

어쨌든 도움이 되길 바랍니다.

0

나는 contentDocument가 아직 생성되지 않았기 때문에이 이벤트가 페이지가로드되어 contentDocument가 존재하므로 호출되므로 iframe의 onload 이벤트를 설정하고이 이벤트에서 디자인 모드를 설정할 수 있다고 생각합니다!