Javascript Prompt() text is partially hidden in Internet Explorer 11

与世无争的帅哥 提交于 2020-01-02 03:35:19

问题


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.


回答1:


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.




回答2:


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.




回答3:


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



来源:https://stackoverflow.com/questions/26746007/javascript-prompt-text-is-partially-hidden-in-internet-explorer-11

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!