开发者

Keeping the format of pasted text in a textarea without visible mark-up info

开发者 https://www.devze.com 2023-01-04 05:29 出处:网络
I had a case where I copied bold text from a web page into a textarea of another page.On paste, the text area kept the text\'s bold format.When I pasted the same text into a text file I could see no m

I had a case where I copied bold text from a web page into a textarea of another page. On paste, the text area kept the text's bold format. When I pasted the same text into a text file I could see no markups or formatting info along with the text. How is the textarea keeping the format of the text?

Thanks in advance.

EDI开发者_StackOverflow社区T:

  • How is the textarea or JS drove text editor formatting the pasted text without any formatting info being passed along with the pasted text?

  • If formatting info is being passed internally by the browser, how is the webpage receiving that info?


Textarea is plain text, so are you sure you didn't paste it into a JS driven text editor in the browser? As for pasting it into a text file... well, this is an OS driven event. It will only work if the application allows formatting of the text (e.g. if you paste it into MS Word or OpenOffice.org Writer).

Answering the additional questions:

Again, the textarea is plain text, so there's no formatting or formatting information. The JS driven editor generates the appropriate code depending on what was pasted. This information is passed by the OS' copy&paste functionality. If it's plain text, then there will be no formatting. If the paste contains formatting codes, it will generate the appropriate markup.

0

精彩评论

暂无评论...
验证码 换一张
取 消