Change format and text displayed with JavaScript prompt()?

后端 未结 5 1647
天涯浪人
天涯浪人 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:12

    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.

提交回复
热议问题