문제

내 페이지에 jhtmlarea jquery 플러그인을 사용하고 있는데 버튼을 클릭 할 수 있습니다. 이제 나는 JHTMLAREA 편집자가 표시되면 초점을 맞추려고 노력하고 있지만 거기에 도착할 수없는 것 같습니다.

이 블로그 게시물을 찾았습니다 jQuery를 사용하여 iframe에서 제어에 중점을 둡니다 이것은 Iframe 내부의 요소로 초점을 설정하는 것에 대해 이야기하고 있습니다. Thickbox 플러그인이 먼저 iframe에 초점을 맞추고 요소에 초점을 맞추면 사용하지만 JHTMLAREA는 요소를 iFrame에 배치하지 않습니다.

그래서 나는 Iframe의 신체 요소를 제대로 선택하지 않거나 .focus() 몸은 나를 위해 아무것도하지 않습니다.

jhtmlarea가 생성하는 결과는 다음과 같습니다.

<div class="jHtmlArea" style="width: 498px;">
  <div class="ToolBar" style="width: 496px;">
    <ul>
      ... removed toolbar code for briefness
    </ul>
  </div>
  <div>
    <iframe style="height: 256px; width: 494px;">
      <html>
        <head>
          <link rel="stylesheet" type="text/css" href="jHtmlArea.Editor.css"></link>
        </head>
        <body>
           <br _moz_editor_bogus_node="TRUE" _moz_dirty=""/>
        </body>
      </html>
    </iframe>
  </div>
  <textarea id="TxtAreaDescription" rows="15" cols="60" name="TxtAreaDescription" style="display: none;"/>

내가 시도한 것 중 일부는 다음과 같습니다.

var iframe = $("iframe");
if (iframe != null) {
    $(iframe).focus();
    $(iframe).contents().find("body").focus();
}

통과 할 수있는 도움에 감사드립니다.

도움이 되었습니까?

해결책

로드 : function () {this.iframe [0] .ContentWindow.focus (); }

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top