2013-04-26 2 views
1

내가 설정할 사용자 정의 컨텐츠 아래에 표시되는 버튼이있는 툴바에 파이어 폭스 확장 기능을 만들고 있습니다.xul 패널 안의 iframe에 값 전달하기

나는이 콘텐츠의 구조를 생성하기 위해 XUL 파일을 사용하고, 그리고 난이처럼 개방되었다

지금
var config = { confirm: false , 
        username:"", 
        password:""}; 

window.openDialog("chrome://myext/content/login.xul", 
     "", 
     "centerscreen=no,all=no,titlebar=no,chrome=yes, 
     toolbar=no,dialog=no,resizable=no,modal=yes", 
     config); 

내가 다른 접근을 채택하고있어, iframe을 사용하여 패널 내부에 동적에 여러 xul 파일 중 하나를 src로 사용하십시오. 이 openDialog와 함께 발생으로

<toolbarpalette id="BrowserToolbarPalette"> 
    <toolbarbutton id="myextToolbarIcon" 
        image='chrome://myext/content/images/myext-mini-logo.png' 
        type="panel" 
        class="toolbarbutton-1 chromeclass-toolbar-additional" 
        tooltiptext="myext"> 
     <panel id="myext-panel" 
       type="arrow" 
       noautofocus="true" 
       consumeoutsideclicks="true" 
       onpopupshowing="startscreen(event);" 
       level="top"> 
      <hbox id="myext-panel-container" align="top"> 
       <iframe id="myext-toolbar-menu" flex="1"/> 
      </hbox> 
     </panel> 
    </toolbarbutton> 
</toolbarpalette> 

은 XUL 파일을 "설정"변수 것을 전송하는 비슷한 방법이 있나요, 다음은 XUL은입니까?

답변

2

당신은 정말 iframe에 값을 "보내기"를 할 수 있지만 iframe 내에서 실행되는 코드를 찾을 수있는 장소에 둘 수 있습니다 - 예를 들어, 그 iframe 태그의의 expando 속성에 :

var frame = document.getElementById("myext-toolbar-menu"); 
frame._myExtConfig = config; 
frame.src = "chrome://myext/content/login.xul"; 

chrome://myext/content/login.xul에서 실행되는 코드는 다음 다음을 수행 할 수

var config = window.frameElement._myExtConfig; 

참고 : window.frameElement

+0

감사합니다. 그 트릭을 않습니다. :) –

관련 문제