2009-11-04 4 views
0

iframe을 designMode = on으로 만듭니다.iframe designMode in firefox

IE에서 웹 사이트를 열고 iframe에 마우스 커서를 올리면 마우스 커서가 텍스트 커서 (큰 글자 1)로 바뀝니다.

Firefox에서 웹 사이트를 열면 corsur가 변경되지 않고 화살표 지점 커서가 유지됩니다.

어떻게 해결할 수 있습니까?

<script language="javascript" type="text/javascript"> 
     designer('content'); 

     function designer(editor) { 
      var browser = navigator.userAgent.toLowerCase(); 
      isIE = (browser.indexOf("msie") != -1); 

      document.writeln('<iframe id="' + editor + '" width="600px" height="600px"></iframe>'); 


      var edit = document.getElementById(editor).contentWindow.document;         
      edit.designMode = "On"; 

      if (!isIE) { 
       document.getElementById(content).contentDocument.designMode = "on"; 
      } 
     } 

    </script> 

답변

1

this page이 도움이 될까요?

+1

... 실제로는 아닙니다. – samuel

+0

왜 안 되니? 그것은 필요한 모든 것을 말해 주어야합니다. –

0
 
Try CSS, that should switch the cursor for you. 

iframe{cursor:crosshair} //all iframes on page 
or 
#content{cursor:crosshair} //just the element with the id "content" 

질문? 변수 의 내용은입니다. document.getElementById (content) .contentDocument.designMode = "on";

편집기과 같은 의미입니까? var edit = document.getElementById (editor) .contentWindow.document;

좋아요, 문제가 있습니다. http://devedge-temp.mozilla.org/viewsource/2003/midas/01/example2-index.html에 대한 링크는 동일한 문제이며 Mozilla의 문제입니다.

+0

너 스스로 시도해 봤어? 작동하지 않습니다. – samuel

0

귀하의 라인 :

if (!isIE) { 
    document.getElementById(content).contentDocument.designMode = "on"; 
} 

거의 확실 읽어야

if (!isIE) { 
    document.getElementById(editor).contentWindow.document = "on"; 
} 

을 당신이 오히려 요소보다, ID null 인 요소를 찾기 위해 비 IE 브라우저를 요구하고 약자로서 id 'content'.

그러나 IFrame에서 텍스트 캐럿을 가져올 수는 있지만 수정할 수는 있습니다.

내가 가지고 올 수있는 최선이었다 : (상단, 즉) iframe이의 첫 번째 줄에 캐럿 에 커서를 회전

document.getElementById(editor).contentWindow.document.style.cursor = "text"; 

, 아마도 그 유일한 편집 비트이기 때문에 그 시점에서.

+0

예, 첫 번째 줄만 있습니다. 모든 라인에서 작동해야합니다 ... – samuel

+0

그러면 iframe에서 더 많은 정보를 입력하거나 Firefox가 작동하지 않는다는 사실에 대해 해결해야합니다. –

0

iframe이 loads 인 경우이 속성을 설정해야합니다.

var edit = document.getElementById(editor).contentWindow.document; 

edit.addEventListener("load", function() { 
    edit.designMode = "On"; 
}, false); 
관련 문제