1 <!DOCTYPE html>
2 <html>
3 <style>
4 .container {
5 margin: 20px 0;
6 }
7 </style>
8 <body>
9 <h1>The Window Object</h1>
10 <h2>The name property </h2>
11
12 <div>
13 <button onclick="setValue('Demo')">Demo</button>
14 <button onclick="setValue('Example')">Example</button>
15 <button onclick="access()">Access</button>
16 </div>
17
18 <p id="result"></p>
19 <script>
20 function access() {
21 const name = window.name;
22 const str = `The window name is : <b>${name}</b>`;
23 document.getElementById("result").innerHTML = str;
24 }
25 function setValue(value) {
26 window.name = value;
27 }
28 </script>
29 </body>
30 </html>