2017-01-31 11 views
0

HTML5에서 작동해야하는 Adobe Captivate 용 위젯을 작성하고 있습니다. 이 위젯에는 전체 화면 모드를 토글하는 버튼이 있습니다.Adobe Captivate에서 위젯의 iframe 속성 편집

function toggleFullscreen(elem) { 
 
    elem = elem || document.documentElement; 
 
    if (!document.fullscreenElement && !document.mozFullScreenElement && 
 
    !document.webkitFullscreenElement && !document.msFullscreenElement) { 
 
    if (elem.requestFullscreen) { 
 
     elem.requestFullscreen(); 
 
    } else if (elem.msRequestFullscreen) { 
 
     elem.msRequestFullscreen(); 
 
    } else if (elem.mozRequestFullScreen) { 
 
     elem.mozRequestFullScreen(); 
 
    } else if (elem.webkitRequestFullscreen) { 
 
     elem.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); 
 
    } 
 
    } else { 
 
    if (document.exitFullscreen) { 
 
     document.exitFullscreen(); 
 
    } else if (document.msExitFullscreen) { 
 
     document.msExitFullscreen(); 
 
    } else if (document.mozCancelFullScreen) { 
 
     document.mozCancelFullScreen(); 
 
    } else if (document.webkitExitFullscreen) { 
 
     document.webkitExitFullscreen(); 
 
    } 
 
    } 
 
} 
 

 
document.getElementById("fullscreen").addEventListener("click", toggleFullscreen);
<button id="fullscren">Toggle full screen</button>

그러나 위젯은 iframe에 삽입되어,이 iframeallowfullscreen 속성이, 따라서 전체 화면을 전환 할 수있는 버튼을 방지하지 않습니다 기본적으로, 플러그인은 같다 방법.

나는 자동으로이 속성을 추가 할 수있는 올바른 구성과 프로젝트를 게시 할 하나의 iframe의 내부에서 일부 자바 스크립트를 실행하여 iframeallowfullscreen 속성을 추가하거나 방법을 찾고 있어요.

나는 자바 스크립트가 parent.document 접근 자 사용하려고하지만 오류 얻을 : 자바 스크립트에서 parent 특성이 충분히 사용

Uncaught DOMException: Blocked a frame with origin "null" from accessing a cross-origin frame. 
+0

버튼은 CPM.js 파일을 편집하고 iframe 속성에'allowfullscreen : "true"'속성을 추가하면 작동합니다. 분명히 프로젝트를 게시 한 후에 파일 편집이 필요하기 때문에 솔루션이 아닙니다. – Dunatotatos

답변

0

합니다. 그런 다음이 온라인으로 allowfullscreen 속성을 추가 할 수 있습니다 : 로컬 소스 (출처 간 보호)에서 게시 된 프로젝트를 표시 할 때

parent.document.getElementsByTagName('iframe')[0].setAttribute('allowFullScreen', 'true'); 

그러나이 작동하지 않습니다. 그것은 웹 서버 (심지어 로컬 호스트)에서 표시 할 때 잘 동작합니다.