JavaScript: window.prompt()

You can no longer simply use prompt(). You must use window.prompt() instead.


    const name = window.prompt("What is your name?");


The code used for index.php is below:


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="../styles.css">
    <title>JavaScript: window.prompt()</title>
</head>
<body>
    
<h1>JavaScript: window.prompt()</h1>

<button id="prompt-button">window.prompt()</button>

<div id="prompt-div"></div>

<script>

    let button = document.getElementById('prompt-button');
    let prompt = document.getElementById('prompt-div');
    button.addEventListener('click', () => {
        console.log("button pressed");
        const name = window.prompt("What is your name?");
        prompt.innerHTML = `
        <h3>${name} is a great name.</h3> `;
    });
</script>

<p>You can no longer simply use prompt(). You must use window.prompt() instead.</p>
<pre>

    const name = window.prompt("What is your name?");

</pre>
<?php
    include('../show_code.php');
    show_code('index.php');
?>
</body>
</html>