niutech / showModalDialog

window.showModalDialog polyfill using a <dialog> element
https://niutech.github.io/showModalDialog/demo.html
Apache License 2.0
177 stars 88 forks source link

dialog.showModal function #30

Closed mhahmadilivany closed 6 years ago

mhahmadilivany commented 6 years ago

hello. I have some huge asp.net website projects, using showModalDialog for popups and using dialog-polyfill. As you know, mozilla doesn't support dialog.showModal() function anymore. So my website have problem for opening popups, all popups have return values too. Changing config of mozilla disturbs users. Is there any solution for me to continue using this function and do not change config?

niutech commented 6 years ago

Have you tried using the dialog polyfill?

mhahmadilivany commented 6 years ago

thanks but it didn't help me. I'm searching minimum cost code changing solution, but I couldn't find anything yet. I edited showModalDialog.js file and solved shoModal() and close() problem, but in async programming I have problem. because editing whole of my websites with spawn(function*(...)) is so hard and now return value is just undefined. I need something to pause code execution on window.showModalDialog(...) line and after closing popup program continues. something such yield does on generator. would you help me?

niutech commented 6 years ago

The polyfill provides the eval() fallback if you don't want to use generators. It throws an exception in showModalDialog(), which stops running the code in the surrounding function. Then it evaluates the rest of the function code (with returnValue set) on dialog close.

mhahmadilivany commented 6 years ago

thank you, I used this, but after throwing exception, the page refreshes in my project! why? I compare my code with your demo and there is no different.

mhahmadilivany commented 6 years ago

excuse me, I closed issue mistakely :)) please continue your helps. thanks

niutech commented 6 years ago

The web page should not refresh on thrown exception unless some JS code in onerror handler forces to do so. Could you provide a minimal Proof of Concept on JSBin/JSFiddle?

mhahmadilivany commented 6 years ago

I got several problems and decided to migrate to jquery modal at last, thank you