๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
  • What would life be If we had no courage to attemp anything?
Language/JavaScript

[JavaScript] ํŒ์—… ์ฐฝ ๊ตฌํ˜„ - window.open

by DevIseo 2024. 5. 20.

[JavaScript] ํŒ์—… ์ฐฝ ๊ตฌํ˜„ - window.open

ํ”„๋กœ์ ํŠธ์—์„œ ๊ธฐํš ๋ช…์„ธ๋ฅผ ๋ฐ”ํƒ•์œผ๋กœ ๋…๋ฆฝ๋œ ํŒ์—… ์ฐฝ์„ ๊ตฌํ˜„ํ•ด์•ผ ํ–ˆ๋‹ค.

JavaScript์˜ window.open ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํŒ์—…์ฐฝ์„ ๊ตฌํ˜„ํ•˜์˜€๋‹ค.

 

window.open ๋ฉ”์„œ๋“œ

์ƒˆ ๋ธŒ๋ผ์šฐ์ € ์ฐฝ์ด๋‚˜ ํƒญ์„ ์—ด ๋•Œ ์‚ฌ์šฉํ•˜๋Š” ๋ฉ”์„œ๋“œ

window.open(url, windowName, [windowFeatures]);

- url : ํŒ์—… ์ฐฝ์— ๋กœ๋“œํ•  ํŽ˜์ด์ง€ URL

- windowName :  ํŒ์—… ์ฐฝ์˜ ์ด๋ฆ„. ๊ฐ™์€ ์ด๋ฆ„์„ ๊ฐ€์ง„ ์ฐฝ์ด ์ด๋ฏธ ์—ด๋ ค์žˆ๋‹ค๋ฉด ํ•ด๋‹น ์ฐฝ์„ ์žฌ์‚ฌ์šฉ.

- windowFeatures : ํŒ์—… ์ฐฝ์˜ ํŠน์„ฑ์„ ์ •์˜ํ•˜๋Š” ๋ฌธ์ž์—ด.

 

์ฝ”๋“œ ์˜ˆ์‹œ

<button onClick="openPopup()">์•ฝ๊ด€ ๋ณด๊ธฐ</button>

<script>
  function openPopup() {
    window.open(
      '/signup/terms',
      'popup',
      'toolbar=no,scrollbars=no,resizable=yes,status=no,menubar=no,width=600,height=700,top=0,left=0'
    );
  }
</script>

 

Reference

 

Window: open() method - Web APIs | MDN

The open() method of the Window interface loads a specified resource into a new or existing browsing context (that is, a tab, a window, or an iframe) under a specified name.

developer.mozilla.org

 

 

Window - Web APIs | MDN

The Window interface represents a window containing a DOM document; the document property points to the DOM document loaded in that window.

developer.mozilla.org

 

๋Œ“๊ธ€