메인메뉴 바로가기

HOME으로 가기


사용자함수 플래시를 새창으로 띄우기 (자바스크립트 API)

페이지 정보

profile_image
작성자 너갱이
댓글 0건 조회 5,145회 작성일 15-05-15 14:39

본문

<button id="btn_open1">열기_1</button>

<button id="btn_open2">열기_2</button>
<button id="btn_close">닫기</button>
 
 
 
 
 
------------- 방식1: 새창으로 플래시소스 띄우고, 다른 플래시 띄울때자동으로 창닫고 새로운 플래시 띄우기 ----------------
 
var Pop = {
    opener : null,
    openWin : function(swf,w,h){
        var xPos = (document.body.clientWidth / 2) - (w / 2); 
         xPos += window.screenLeft;  //듀얼 모니터일때....
        var yPos = (screen.availHeight / 2) - (h / 2);
        
        if(Pop.opener) {
            Pop.closeWin(swf,w,h);
        } 
         else {
            Pop.opener = window.open(null,null,"width="+w+",height="+h+",left="+xPos+",top="+yPos);
            Pop.opener.document.write('<html><head><title>FlashWindow</title></head><body style="margin:0;padding:0;"><div style="width: 100%; height: 100%; position: absolute; left: 0px; top: 0px; overflow: hidden;"><embed type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" src="'+swf+'" quality="high" bgcolor="#ffffff" width="100%" height="100%" align="middle" allowScriptAccess="always" allowFullScreen="true" menu="false" base="." flashVars="" /></div></body></html>');
            
            Pop.opener.focus();
        }
   },
   closeWin : function(swf,w,h){
            Pop.opener.close();
            Pop.opener = null;
            if(swf) {
                setTimeout(function() {
                    Pop.openWin(swf,w,h);
                },100);
            }
   }
}
 
 
 
 
 
 
 
-----------------  방식2: 새창으로 플래시소스 띄우고, 다른 플래시 띄울때 현재창에 업데이트, 창사이즈 틀리면 resize 모드 --------------
 
var Pop = {
    opener : null,
    w : null,
    h: null,
    openWin : function(swf,w,h){
        var xPos = (document.body.clientWidth / 2) - (w / 2); 
        xPos += window.screenLeft;  //듀얼 모니터일때....
        var yPos = (screen.availHeight / 2) - (h / 2);
        
        if(Pop.opener) {
            if(Pop.w != w || Pop.h != h){ 
                Pop.opener.resizeTo(w,h);
                Pop.opener.document.write("");
            }
            //Pop.closeWin(swf,w,h);
        }
        else {
            Pop.opener = window.open(null,null,"status=no,toolbar=no,scrollbars=no,width="+w+",height="+h+",left="+xPos+",top="+yPos);
        }
        
//setTimeout(function() {
Pop.opener.document.write('<html><head><title>FlashWindow</title></head><body style="margin:0;padding:0;"><div style="position:absolute;width: 100%; height: 100%; position: absolute; left: 0px; top: 0px; overflow: hidden;"><embed type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" src="'+swf+'" quality="high" bgcolor="#ffffff" width="100%" height="100%" align="middle" allowScriptAccess="always" allowFullScreen="true" menu="false" base="." flashVars="" /></div></body></html>');
//},1000);
        Pop.opener.focus();
        Pop.w = w;
        Pop. h = h;
   },
   closeWin : function(swf,w,h){
            Pop.opener.close();
            Pop.opener = null;
            Pop.w = null;
            Pop.h = null;
            if(swf) Pop.openWin(swf,w,h);
   }
}
 
 
 
 
 
//플래시에서 호출하는 API 예제
document.getElementById("btn_open1").onclick = function(){ Pop.openWin("pageflipdata/extend/dart.swf",1024,768); } //1024 플래시창 띄워라.
document.getElementById("btn_open2").onclick = function(){ Pop.openWin("pageflipdata/extend/dic.swf",800,600); } //800 플래시 창 띄워라.

document.getElementById("btn_close").onclick = function(){ Pop.closeWin(); } //플래시 창 닫아라. 

댓글목록

등록된 댓글이 없습니다.