티스토리 뷰

location 객체가 가지고 있는 replace함수는 해당 페이지로 이동하는 것이 아닌 "변경"해준다.

따라서 브라우저에서 호출한 페이지로 이동하지만, 뒤로가기 버튼은 사용할 수 없다.

<!DOCTYPE html>
<html lang="ko">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>팝업 창 표시하기</title>
</head>
<body>
	<h1>현재 페이지</h1>
	<button onclick = "location.replace('http://www.naver.com')">네이버로 변경</button>
	<!--  뒤로가기 불가능 -->
</body>
</html>

 

Comments