Javascript Prompt() text is partially hidd

2019-04-24 16:11发布

I am trying to display a "larger than normal" amount of text in a prompt() box. When calling the javascript prompt() function in Internet Explorer 11, a large portion of my text is being hidden. It seems to only support 2 lines of text. Chrome, Firefox and Opera seem to work fine. This seems to be just an IE issue.

Here is a fiddle that demonstrates the problem: JSFiddle Example

prompt("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum     has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.");

I am only able to see this text "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when". The rest is not displayed.

I'm afraid I already know the answer, but is there a reason why this is happening? I would prefer to use the prompt() and not use a custom modal.

3条回答
等我变得足够好
2楼-- · 2019-04-24 17:07

You can use one of these alerts, even simpler than modals:

If you use Bootstrap, Bootboxjs is for you: http://bootboxjs.com/

Sweetalert is also simple and cool: http://tristanedwards.me/sweetalert

查看更多
爷、活的狠高调
3楼-- · 2019-04-24 17:11

The IE version of prompt does not dynamically resize.

You should only be using prompts for small messages, not whole paragraphs. like

e-mail:

or

username:

You should have any explanation stuff inline on the web page. or better yet don't use prompt's at all and use inline forms.

查看更多
疯言疯语
4楼-- · 2019-04-24 17:13

You should probably not use window.prompt to begin with. It is largely frowned upon due to the fact it blocks the thread, and thus can halt your application. The web today has moved towards leveraging the asynchronous nature of JavaScript; this should distance us from things like alert, prompt, etc.

Presently the prompt is not supported in Immersive Internet Explorer ("Metro"), Internet Explorer on the xbox, or Windows Web Applications (formerly Windows Store Applications). Instead, you are encouraged to leverage third-party tools and libraries (such as Bootstrap, jQuery UI, etc) for these types of needs.

All of this being said, it is a genuine difference between Internet Explorer and other modern browsers, and as a result I have opened up an issue internally for the IE team to discuss.

查看更多
登录 后发表回答