Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- spring
- 배열
- SQL
- workbench
- Git_정리
- DML
- json
- 인덱스
- asp.net
- 자바스크립트
- Linux_명령어정리
- 다이어그램
- 아파치톰캣
- vb.net
- CSS
- Linux
- Spring_에러정리
- HTML
- SQL_용어정리
- jsp
- MySQL
- 인스턴스
- 자바
- java
- JavaScript
- git
- github
- 이클립스
- Spring_오류정리
- Git_명령어정리
Archives
- Today
- Total
데브마우스
[JavaScript]Uncaught TypeError: window.open is not a function 에러 발생 시 확인해야 할 부분 본문
JavaScript/JS: 에러 정리
[JavaScript]Uncaught TypeError: window.open is not a function 에러 발생 시 확인해야 할 부분
데브마우스 2023. 12. 3. 17:26자바스크립트에서 Uncaught TypeError: window.open is not a function 에러 발생 시 제일 먼저 확인해야 할 부분이 있습니다.
open을 변수명으로 사용하신적이 있나요?
자바스크립트는 예약어가 엄격하지 않습니다. 그렇기 때문에 개발자가 open이라는 변수명을 짓고 사용할 경우 window.open의 open 함수를 사용할 수 없게 됩니다.
아래는 에러가 발생했던 상황을 재현한 코드입니다.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="test">
<button id="open">
버튼입니다.
</button>
</div>
<script>
var open = document.getElementById("open");
open.addEventListener("click", oepnFunc);
function oepnFunc() {
alert("test");
}
var newTab = window.open("devmouse.tistory.com");
</script>
</body>
</html>
'JavaScript > JS: 에러 정리' 카테고리의 다른 글
[JavaScript:오류정리]자바스크립트에서 변수 이름 작성 시 주의해야할 이름 (0) | 2023.12.17 |
---|---|
[JavaScript] console.log()를 입력했는데 undefined만 나올 때 해결 방법 (0) | 2023.12.17 |
알쏭달쏭한 자바스크립트의 변수 이름과 예약어 (0) | 2023.12.04 |