Equivalent to window.showModalDialog for Google Chrome

1

Hello, I need a window.showModalDialog equivalent to open as modal and wait for it to continue the font, when I open it it becomes asynchronous from my site and does not work together.

ps window.showModalDialog works in IE

    
asked by anonymous 25.10.2017 / 16:39

1 answer

1

Hello, according to the Mozilla documentation this feature is already deprecated and has been removed from Chrome and Firefox.

You can now use the <dialog> tag.

Excerpt taken from the documentation itself

HTML

<!-- Simple pop-up dialog box, containing a form -->
  <dialog open id="favDialog">
    <form method="dialog">
      <section>
        <p><label for="favAnimal">Favorite animal:</label>
        <select id="favAnimal">
          <option></option>
          <option>Brine shrimp</option>
          <option>Red panda</option>
          <option>Spider monkey</option>
        </select></p>
      </section>
      <menu>
        <button id="cancel" type="reset">Cancel</button>
        <button type="submit">Confirm</button>
      </menu>
    </form>
  </dialog>

  <menu>
    <button id="updateDetails">Update details</button>
  </menu>

JS

(function() {
  var updateButton = document.getElementById('updateDetails');
  var cancelButton = document.getElementById('cancel');
  var favDialog = document.getElementById('favDialog');

  // Update button opens a modal dialog
  updateButton.addEventListener('click', function() {
    favDialog.showModal();
  });

  // Form cancel button closes the dialog box
  cancelButton.addEventListener('click', function() {
    favDialog.close();
  });
})();

Documentation: link link

    
25.10.2017 / 17:42