2

I'm using JavaScript's prompt() function.

  var favorite = prompt('What is your favorite color?', 'RED');

I'm using IE 7 and the prompt box that opens has a title bar that says : 'Explorer User Prompt' and further text that says 'Script Prompt:' Then beneath this is my text : 'What is your favorite color?' Also the 'OK' and 'Cancel' buttons appear in the far right side of the prompt box and the text entry box appears at the very bottom of the dialogue.

Is there any way to change the title bar, remove the text 'Script Prompt', and put the OK and cancel buttons beneath the text entry box?

brasofilo
  • 25,496
  • 15
  • 91
  • 179
user840930
  • 5,214
  • 21
  • 65
  • 94

5 Answers5

2

Yes. By not relying on browser UI (which is actually disabled by default in some browsers) and instead making your own.

All it takes is a simple modal dialog with a form in, and you're all good. The only downside is that it won't be blocking anymore (if you can consider that a downside), so you need to put the rest of the code inside a callback that the prompt calls when it's closed.

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592
  • 1
    There are third-party modal popup jQuery controls that fade out the page and can block entry until OK/Cancel is clicked. – Dave Swersky May 08 '12 at 16:19
  • True, there are. Of course, I just wrote my own in about twenty lines of code that's much easier to use (at least for me). I get unlimited buttons, with custom text and each with their own function, as well as whatever input I want (or any HTML for that matter) and all kinds of useful features that probably aren't in the jQuery one because it'd be too complicated for most people to use... – Niet the Dark Absol May 08 '12 at 16:29
1

No I don't believe so. The problem was that people would use prompts maliciously so microsoft added that to make it look more like it was a page specific prompt and not a IE prompt.

You can do an in page dialog with jQuery or something:

http://www.abeautifulsite.net/blog/2008/12/jquery-alert-dialogs

Developer
  • 2,021
  • 12
  • 11
0

Short answer: no.

Longer answer: No, but you can roll your own popups with jQuery's UI library or by hacking up something with the DOM yourself.

Elliot Bonneville
  • 51,872
  • 23
  • 96
  • 123
0

No, there isn't.

The closest you can come is to mock up a fake one using DOM elements.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
0

Not exactly what's being asked, but the only way I found to give the prompt box some formatting...

Using this answer, this answer and these HTML symbols, one can get creative and achieve this:


prompt example

Demonstration:

var balls = '\u25CD'.repeat(24),
    blue = '\u27BF', 
    red = '\u274C', 
    yellow = '\u2728', 
    green = '\u2705',
    arrow = '\u25B8';
    
window.prompt(balls+' \u25C9 '+balls+'\rWhat is your favorite color?\r\t'+arrow+' B\u0332lue '+blue+'\r\t'+arrow+' R\u0332ed '+red+'\r\t'+arrow+' Y\u0332ellow '+yellow+'\r\t'+arrow+' G\u0332reen '+green);
brasofilo
  • 25,496
  • 15
  • 91
  • 179