나는 시스템과 상호 작용하는 일부 권한있는 JavaScript 코드와 함께 chromeless 애플리케이션을 가지고 있습니다. 이제 서버에 호스팅 된 애플리케이션과 함께 특권 JavaScript (jsctypes)를 매시업하고 싶습니다. 원격 애플리케이션은 Iframe에로드되고 chromeless 애플리케이션과 원격 애플리케이션 간의 상호 작용은 html5 postMessage를 통해 발생합니다.iframe 교차 도메인 통신 및 chromeless 도메인
부모가 포함 된 Iframe에 메시지를 게시하고 e.origin이 "resource : \ app" 인 Iframe에서 성공적으로 수신하는 반면 iframe에서 resource.domain으로 window.parent로 postMessage를 보내려고하면 : 응용 프로그램 부모에서의 onMessage 리스너가 실행에
레이아웃
,를 호출되지 않습니다> 크롬 예 \ testapp를 \ index.html을 XUL 응용 프로그램은 크롬 빌드 폴더에 생성되고 다음이 표시됩니다. 어떤 도움을 주시면 감사
var onmessage = function(e) {
alert("message");
}
if(typeof window.addEventListener != 'undefined') {
window.addEventListener('message', onmessage, false);
}
else if(typeof window.attachEvent != 'undefined') {
window.attachEvent('onmessage', onmessage);
}
학부모의 onMessage
[Code]
var sendMessage = function(){
var iframe = window.parent;
iframe.postMessage("test","resouce://app");
};
[/Code]
Iframe에
내부+-----------------------------------Chromeless----+ | | | --- MessageToIframeButton | | | | +--------------------------Iframe--+ | | |Msg Recvd from: resource://app | | | |(this is the message from parent) | | | | | | | | _TxtBox_sendMessage | | | | | | | | | | | | | | | +----------------------------------+ | | Msg Recvd: | | | +-------------------------------------------------+
PostMessage를!
팔란, 나는 사용자 정의 이벤트를 사용하여 크로스 도메인 통신을 구현하려하지만 Priviliged 된 index.html에서
성공하지 못했습니다 [무 크롬 예 \ testapp를 \ index.html을] :
var myExtension = {
myListener: function(evt) {
alert("Received from web page: " +
evt.target.getAttribute("attribute1"));
}
}
document.addEventListener("MyExtensionEvent", function(e) {myExtension.myListener(e); }, false, true); // The last value is a Mozilla-specific value to indicate untrusted content is allowed to trigger the event.
//content.addEventListener("MyExtensionEvent", function(e) {myExtension.myListener(e); }, false, true); //Also tried with content.
에서 원격 응용 프로그램 iframe이 remote.html : 버튼의 클릭에 ,
var element = document.createElement("MyExtensionDataElement");
element.setAttribute("attribute1", "foobar");
document.documentElement.appendChild(element);
var evt = document.createEvent("Events");
evt.initEvent("MyExtensionEvent", true, false);
element.dispatchEvent(evt);
트리거 된 이벤트 수행하는 권한을 부모 도메인에 있지 거품 iframe 자체에 eventListener가 추가되면 전달 된 이벤트가 수신되고 마찬가지로 맞춤 이벤트가 권한있는 컨텍스트 (index.html)에서 생성 된 경우 부모 창은 알림을 받지만 계층 구조 간에는 전달되지 않습니다. 나는 기본적인 것을 놓치고 있는가 ??
iframe에서 '*'및 postMessage로 도메인을 설정하면 메시지는 부모 창이 아니라 Iframe에서 수신합니다. – Yeshvanthni
동일한 샘플 html 페이지 (도메인이 '*'로 설정된 경우)는 firefox에서 파일을 열거 나 Chromeless 배치를 실행하고 브라우저에서 html 파일을 열 때 부모 창에 메시지를 게시합니다.이 경우 파일과 동일하며 권한이 부여 된 것입니다 javascript가 실행되지 않거나 XULaplication처럼 동작하지 않습니다. – Yeshvanthni
[link] http : // stackoverflow가 원인입니다.coz/questions/5463429/모질라에서 크롬을 사용하지 않는 top-from-take-over-in-mozilla. Iframe 상단 창을 만드는 동작. ?? – Yeshvanthni