2011-05-11 3 views
3

프레임 셋과 3 개의 프레임이있는 jquery-ui-1.8을 사용하여 작은 웹 페이지를 만듭니다. jquery-ui를 사용하여 다른 프레임에서 대화 상자를 팝업하는 방법

<frameset id="mainFrame"cols="25%,*,25%"> 
    <frame id="f1" src="test.php"></frame> 
    <frame id="f2" src="test2.php"/> 
    <frame /> 
</frameset> 

그러면 I는 첫 번째 프레임 (F1) 및 제 프레임에 장착되는 test2.php하는 DIV에로드 파일 test.php에 버튼을 추가했다.

<div id="testdiv"> this is test 2</div> 

그러면 I는 I가 F1의 버튼을 클릭하면 제 프레임 (F2)에 "testdiv"에서 JQuery와 대화를 팝업 할 필요가있다.

다음 스레드에서 주어진 해결책을 시도해 보았습니다. [1] - Display jquery dialog in parent window

var $jParent = window.parent.jQuery.noConflict(); 
var dlg1 = $jParent('#testdiv'); 
dlg1.dialog(); 

및 [2] - jQuery UI dialog display inside frame, from bookmarklet?

var frame = window.frames[1]; 
var div = $(frame.document.getElementById("testdiv")); 
div.html("My popup contents"); 
div.dialog(); 

그러나 이러한 팝 업 두 번째 프레임 내에서 대화의 비. 이 문제를 해결하는 데 도움을 줄 수 있습니까?

답변

3

이 방법으로 테스트를 해보는 것이 가장 좋은 방법은 아니지만 시도해 볼 수는 있습니다. (주의 : 속성 추가하는 것을 잊지 마세요 -> 이름 = "F2"< - iframe이 F2)에 test.php에

을 : test2.php에서

<button onclick="parent.f2.$('#testdiv').dialog('open');">test</button> 

:

<link type="text/css" href="jquery-ui.css" /> 
<script type="text/javascript" src="jquery.js"></script> 
<script type="text/javascript" src="jquery-ui.js"></script> 
<script type="text/javascript"> 
$(function() { 
    $("#testdiv").dialog({ 
    autoOpen: false 
    }); 
}); 
</script> 

<div id="testdiv"> hello world! </div> 
+0

감사합니다. bungdito, 괜찮습니다. 내 시간이 많이 절약되었습니다. :) – Thilanka

관련 문제