skip to Main Content

I am making a program in JavaScript that uses the canvas. I want to get user input from the prompt() function, but that has been deprecated in Electron Fiddle that I am using.

What is an alternative to prompt() that does not use any HTML elements?

2

Answers


  1. there is no alternative for prompt() built-in in the window object

    but if you want it , there is libraries that do the same thing for you

    but they work with html elements

    pure popup could help you

    Login or Signup to reply.
  2. Maybe you can use the <dialog> element?

    const dialog01 = document.getElementById('dialog01');
    
    document.forms.form01.open.addEventListener('click', e => {
      dialog01.showModal();
    });
    
    dialog01.addEventListener('close', e => {
      console.log(document.forms.dialogform.text.value);
    });
    <dialog id="dialog01" closed>
      <p>This is the dialog</p>
      <form method="dialog" name="dialogform">
        <input type="text" name="text">
        <button>OK</button>
      </form>
    </dialog>
    <form name="form01">
      <button name="open" type="button">Open dialog</button>
    </form>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search