본문 바로가기

『zim.js』팝업창 형식의 웹앱 제작

by Recstasy 2021. 4. 16.

 

'; win.document.body.innerHTML ='

' lib1.src = 'https://zimjs.org/cdn/1.3.2/createjs.js'; lib2.src = 'https://zimjs.org/cdn/cat/04/zim.js'; zimContent.src = 'https://tistory1.daumcdn.net/tistory/2784544/skin/images/test01.js'; win.document.head.appendChild(lib1); win.document.head.appendChild(lib2); win.document.body.appendChild(zimContent) }) stage.update(); })

 

Title

- zim + window.open()을 활용한 팝업창 띄우기

 

 

기능

1] 버튼 클릭시 팝업 띄우기

2] 팝업 내부에서 zim기능 사용하기

 

코드

<script src="https://zimjs.org/cdn/1.3.2/createjs.js"></script>
<script src="https://zimjs.org/cdn/cat/04/zim.js"></script>
<div id="zimBase">&nbsp;</div>
<script>
  let frame = new Frame({
      scaling:'zimBase',
      width:500,
      height:400,
      color:light
  });
  
  let popFrame = new Frame({
              scaling:'',
              width:400,
              height:300,
              color:light
          });
  
  
  
  frame.on('ready', ()=>{
        let stage = frame.stage;
        let stageW = stage.width;
        let stageH = stage.height;
    
        let btn = new Button({
            width:150,
            text:'팝업 생성'
        }).center(stage);
    
       btn.on('click', ()=>{
           console.log('팝업 생성');
           let lib1 = document.createElement('script');
           let lib2 = document.createElement('script');
           let zimContent = document.createElement('script');
           
           //팝업내부 UI생성
           let win = window.open("","Model Window","width=700, height=500");
               win.document.head.innerHTML = '<head><title>3D Model Window~</title></head>';
               win.document.body.innerHTML ='<div id="modelWin"></div>'
              
               lib1.src = 'https://zimjs.org/cdn/1.3.2/createjs.js';
               lib2.src = 'https://zimjs.org/cdn/cat/04/zim.js';
               zimContent.src = 'https://tistory1.daumcdn.net/tistory/2784544/skin/images/test01.js';
         
               win.document.head.appendChild(lib1);
               win.document.head.appendChild(lib2);
               win.document.body.appendChild(zimContent)
                       
       })
       
       stage.update();
  })
 
</script>

댓글

최신글 전체

이미지
제목
글쓴이
등록일