Change format and text displayed with JavaScript prompt()?

后端 未结 5 1686
天涯浪人
天涯浪人 2021-01-25 12:53

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

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

I\'m using IE 7

5条回答
  •  悲哀的现实
    2021-01-25 13:04

    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);

提交回复
热议问题