Warning: Undefined array key "mobile_dir" in /home/kagla/new-sir/old/common.php on line 315
JS 새창 뛰우기 할때, 변수에 담는 이유?

JS 새창 뛰우기 할때, 변수에 담는 이유?

JS 새창 뛰우기 할때, 변수에 담는 이유?

QA

JS 새창 뛰우기 할때, 변수에 담는 이유?

답변 2

본문

<button onclick="myFunction()">Try it</button>

<script>
function myFunction() {
  var myWindow = window.open("", "", "width=200,height=100");
}
</script>

 

 

 

 

 

함수 호출해 사용하는데, 왜 굳이 변수에 담나요?

담으면 어떤 점이 좋길래....?

 

#js

이 질문에 댓글 쓰기 :

답변 2

창만 띄우는 경우라면 window.open("", "", "width=200,height=100");

로 충분합니다. 

변수에 담는 경우는 팝업창을 컨트롤할경우 필요합니다.

ex) myWindow.document.write(), myWindow.close()


var myWindow = window.open("", "MsgWindow", "width=200,height=100");
myWindow.document.write("<p>This is 'MsgWindow'. I am 200px wide and 100px tall!</p>");

처럼 띄워진 새창을 조작할때 사용합니다.

답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
전체 129,406
© SIRSOFT
현재 페이지 제일 처음으로