• 코드:
​x
 
1
<!DOCTYPE html>
2
<html lang="ko">
3
​
4
<head>
5
    <meta charset="UTF-8">
6
    <title>JavaScript BOM Location Object</title>
7
</head>
8
​
9
<body>
10
​
11
    <h1>현재 창에 문서 불러오기</h1>
12
    <p>아래 버튼을 눌러 새로운 문서를 연 후에 브라우저의 뒤로 가기 버튼을 눌러보세요!</p>
13
    <button onclick="openDocument()">새로운 문서 열기</button>
14
    <button onclick="openDocumentWithReplace()">이전 문서 삭제 후 새로운 문서 열기</button>
15
    
16
    <script>
17
        function openDocument() {
18
            location.assign("/index.php");
19
        }
20
        function openDocumentWithReplace() {
21
            location.replace("/index.php");
22
        }
23
    </script>
24
    
25
</body>
26
​
27
</html>