nwjs / nw.js

Call all Node.js modules directly from DOM/WebWorker and enable a new way of writing applications with all Web technologies.
https://nwjs.io
MIT License
40.35k stars 3.88k forks source link

Alert with title #7797

Closed JohnLego closed 2 years ago

JohnLego commented 3 years ago

Hello, I would like to set an alert dialog with a title.

NWJS Version : 0.57.1 Operating System : Windows 10

Expected behavior

I want to have the ability to set title in alert (not as css/js import plugin).

Actual behavior

I can only set text if I use alert() or global.alert()

bluthen commented 2 years ago

Since alert() is from chromium, I don't think you can. Also alert() almost was removed a few months ago, and it might be again. I'd recommend just using a js dialog like sweet alert or something to make it more future proof.

JohnLego commented 2 years ago

Thanks. Also, alert() is still working from menu items and web pages in nw.js so, I do not know what are you talking about.

sysrage commented 2 years ago

Thanks. Also, alert() is still working from menu items and web pages in nw.js so, I do not know what are you talking about.

As @bluthen explained, this is not an NW.js bug (or even a bug at all). This is a security "feature" of Chromium, which NW.js is built on. This is not something that can/should be changed and the issue should be closed.

bluthen commented 2 years ago

alert() is still working from menu items and web pages in nw.js so, I do not know what are you talking about.

https://developer.chrome.com/blog/deps-rems-91/

There was an attempt to remove alert for cross-origin iframes and I suspect a want to remove it in all cases. It got reverted but I don't know if this is the end of it. Maybe I should have just left this detail out because who knows what happens in the future.

I'd still recommend using sweetalert or something instead. alert might work when you first start your project but when you want to add more features or customize it, you run into a wall because it is very limited and has side effects. You are usually better off doing something else from the beginning. Maybe just some unsolicited advice based on past experience. You are the one working on your project so do what you want.

TheJaredWilcurt commented 2 years ago

@JohnLego

As mentioned by others, this is a feature of Chromium, and not related to NW.js. Alternatively, you can use new Notification() which is supported in NW.js, Chromium, Firefox, etc. It's sort of a desktop notification, but built in to the browser:

And if you'd like to use an actual desktop notification supplied by the OS, there is a node module that handles this for you:

Closing this issue.