Large text in TextArea freezes computer

后端 未结 5 2027
无人共我
无人共我 2020-12-20 19:09

When I try to set the value of a textarea with a large text (for example a string length of 600000), the browser (Firefox 3.5.3) freezes.

The text is in 1 line so t

相关标签:
5条回答
  • 2020-12-20 19:30

    Like what other people are saying, this may not be the best solution depending on what sort of data you are trying to handle.

    If you really need this, you may want to consider using Javascript and having an "editable" DIV. I've never tried this myself, but I've always kept it as an option in case I wanted an alternative to the very limited textarea form element.

    I would just start here and do a bit more research into the topic:

    How to make an HTML <div> element editable cross-browser?

    Theoretically this shouldn't have any limit on how much text it contains or you can paste into it as far as I know.

    0 讨论(0)
  • 2020-12-20 19:37

    The maximum size for a textarea in Firefox is 64K (it could be just 32K, I can't recall). 600,000 characters is larger than that. If the size of the text that you're pasting into the textarea does in fact exceed that size, then there's nothing you can do about it.

    Of course, one alternative would be to put some type of restriction on the data going into the field and then give the user some feedback as to why their data won't fit.

    0 讨论(0)
  • 2020-12-20 19:37

    Disable the spell checker (in Firefox 7.0 uncheck the 'Check my spelling as I type' option in the Preferences window).

    You can also add the spellcheck="false" attribute to the textarea in HTML.

    0 讨论(0)
  • 2020-12-20 19:40

    There is basically no controls that are designed for that kind of data sizes, because it simply doesn't make any sense to present all that informaton at once to the user.

    Even if the control would handle the data, it would be practically unusable as you can't navigate through the data in any reasonable fashion.

    0 讨论(0)
  • 2020-12-20 19:44

    The answer comes certainly a bit late, but in order to speed up your paste operations of large chunks of text in a textarea or editable div, simply disable autocomplete:

    <div onClick="this.contentEditable='true';" autocomplete="off">
      lorem ipsum dolor lorem ipsum dolorlorem ipsum dolor
    </div>
    
    0 讨论(0)
提交回复
热议问题