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

본문
<button id="btn_open1">열기_1</button>
<button id="btn_open2">열기_2</button>
<button id="btn_close">닫기</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) {
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();
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;
Pop.opener = null;
if(swf) {
setTimeout(function() {
Pop.openWin(swf,w,h);
},100);
}
setTimeout(function() {
Pop.openWin(swf,w,h);
},100);
}
}
}
----------------- 방식2: 새창으로 플래시소스 띄우고, 다른 플래시 띄울때 현재창에 업데이트, 창사이즈 틀리면 resize 모드 --------------
var Pop = {
opener : null,
w : null,
h: 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;
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;
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_open2").onclick = function(){ Pop.openWin("pageflipdata/extend/dic.swf",800,600); } //800 플래시 창 띄워라.
document.getElementById("btn_close").onclick = function(){ Pop.closeWin(); } //플래시 창 닫아라.
- 이전글어떤 자동차가 빠를까요? 15.05.15
- 다음글그림배경이나 플래시화면 위에 유튜브동영상 레이어팝업 띄우기. 15.05.15
댓글목록
등록된 댓글이 없습니다.

