I'm working on a Chrome extension that will pop up a dialog box in the center of the screen when the user hits a keyboard shortcut. It will then use JavaScript to asynchronously load in content from the MediaWiki API. But I'm having difficulty figuring out how to create and display a dialog with JavaScript. I don't want to use the Chrome html-popup
browser action, because it appears off in the corner of the screen.
I know how to use JavaScript to display an existing HTML dialog box, as this answer explains, but I don't know how to insert one into the DOM. I don't want to use JavaScript's alert
function, since that opens a separate window. So is there a way to create and display an HTML modal dialog when an event triggers a JavaScript function in a chrome extension?
getSelection().toString()
. I do, however, need to make a cross-domain request to the MediaWiki API. As I understand it, I can declare a permission in the chrome extension manifest to allow cross-site domain requests, though it isn't usually allowed with JS. Is that right? – Jonathan Cox Aug 21 '15 at 4:01