Quantcast
Channel: Active questions tagged return-value - Stack Overflow
Viewing all articles
Browse latest Browse all 228

What is the correct value of HTML 's `returnValue` per spec when the dialog is canceled with Esc?

$
0
0

Check this dialog box implementation.

const open = document.getElementById('open')const dlg = document.getElementById('dlg')open.addEventListener('click', function () {  dlg.showModal()})dlg.addEventListener('close', function () {  console.log('You chose:', dlg.returnValue)})
<button id="open">Open</button><dialog id="dlg"><form method="dialog"><p>Are you sure?</p><button value="no">No</button><button value="yes">Yes</button></form></dialog>

Follow these steps:

  1. Run the above code snippet.
  2. Click "Open" button.
  3. Click "No" in the dialog box.
  4. The console log shows You chose: no.
  5. Click "Open" button again.
  6. Cancel the dialog box by pressing Esc.
  7. The console log shows You chose: no.

On Firefox v143, step 7 prints:

You chose: no

On Chrome v140, step 7 prints:

You chose:

Is the value of returnValue when we cancel the dialog box with Esc left undefined in the spec? Or does the spec specify the returnValue in this situation?


Viewing all articles
Browse latest Browse all 228

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>