| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 |
Tags
- AWS
- 티스토리챌린지
- 구조체
- Kubernetes
- Infra
- typescript
- 관측 가능성
- 오블완
- GoF
- database/sql
- golang
- javascript
- MSA
- goland
- 디자인패턴
- elasticsearch
- sqs fifo queue
- context7
- GIT
- AI
- blank import
- esbuild
- logging
- 캡슐화
- Intellij
- 통합 로깅 시스템
- RDS
- go
- go-sql-driver
- replication lag
Archives
- Today
- Total
Fall in IT.
window.opener 알아보기 본문
반응형
안녕하세요.
오늘은 window.opener에 대해서 알아보도록 하겠습니다.
샘플 코드는 여기에서 확인해주시기 바랍니다.
window.opener이란?
- 윈도우 A에서 window.open()을 통해 윈도우 B를 열었다면, window.opner를 통해 윈도우 B에서 윈도우 A를 제어할 수 있다.
Sample Code
// index.js (윈도우 A)
window.onload = () => {
setEventHandler();
main();
}
function setEventHandler() {
// 윈도우 B 열기 버튼
document.getElementById("window-open-button").onclick = () =>
{
window.open("window-b.html", "_blank", 'width=425, height=550, resizable=0, scrollbars=no, status=0, titlebar=0, toolbar=0, left=435, top=250');
}
}
function main() {
console.log("called main");
}
function eventListener() {
alert('called event listener');
}
// window-b.js (윈도우 B)
window.onload = () => {
main();
}
function main() {
console.log("called main");
window.opener.window.eventListener();
}
참조
- https://github.com/leeduyoung/window-opener-sample
- https://developer.mozilla.org/ko/docs/Web/API/Window/opener
모두 즐거운 코딩하세요~
반응형
'프로그래밍언어 > Javascript & Typescript' 카테고리의 다른 글
| Typescript 싱글톤 패턴 (0) | 2019.04.07 |
|---|---|
| javascript 숫자와 숫자 사이의 랜덤 숫자 뽑는방법 (1) | 2018.12.13 |
| Javascript every 메소드 사용하기 (1) | 2018.11.21 |
| Typescript Partial, Required, Pick 사용방법 (1) | 2018.09.17 |
| Typescript Generic이란? (1) | 2018.08.30 |
Comments