问题
How do I create an alert in Chrome using JavaScript that opens a text box in the middle of the browser window and washes out the background, like so:

rather than an alert that just pops up an entirely new window (in my case in the Linux Mint GTK theme):

If I type alert()
into the console, I get an alert that looks like the latter, in a separate window.
回答1:
You should use the dialog element. Something like this:
HTML:
<dialog>
This is a dialog.<br>
<button>Close</button>
</dialog>
Javascript:
var dialog = document.querySelector("dialog")
dialog.querySelector("button").addEventListener("click", function() {
dialog.close()
})
dialog.showModal()
来源:https://stackoverflow.com/questions/32079003/using-javascript-to-create-a-chrome-style-alert