Author: Wang Xianrong
Conclusion
Javascript obtains the string in the textarea text box. If a carriage return or line break is contained,\ NInstead of what we usually see\ R \ n".
Problems Found
When creating a small website today, You need to replace the English, Chinese, and English semicolons entered by the user with the Chinese semicolons. During the compilation of
Write an online editor for UBB, because the pop-up window is not used
Code At the end of textarea, I could not insert the cursor before, so I went online and went crazy to find information. I finally found out how to get the position in textarea, however, if textarea has a lot of content, it will flash. The Code is as follows.
Function getpos (OBJ)
{
OBJ.
One JavaScript instance every day-processing each line of characters in textarea, javascripttextarea
How to use javascript to save the textarea value to an array by row
For example, if the ID of textarea is test_textarea js, it can be written as follows:Var
Display the javascript code of the html page in textarea. I want to display the html page written in textarea as html.
I know that tools such as htmledit can't be used. I only need simple display.
1st floor
You can use document. write ()
If you want to edit it, I think you may still need tools like htmledit. I am studying fckeditor, which has a few types and has
Not much to say directly on the codeOrganize original: http://blog.csdn.net/liujin4049/article/details/1244065Onfocus= "Savepos (This)" rows= "cols=" > JavaScript Gets the cursor location in textarea, add value
JavaScript focus event, mouse event and scroll event usage details, and javascript Usage Details
Focus event
These events are generally used in combination with the document. hasFocus () method and the document. activeElement attribute. Mainly include:
Blur: the element loses focus
Replace the line breaks contained in the strings in textarea with the javascript code on the first floor of amp; lt; br amp; gt;
Textarea. value. replace (/\ n/g ,"
");
2nd floor
S = textarea. value. replace (/\ r \ n/g ,"
");
Third floor
Change immediately when pressed
V id = "a" contentEditable = "true" style = 'b
Directly run the Code:Solution 1: [Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]Solution 1 in various browsers, the text box is no problem with the adaptive growth of content; however, the contraction of the deleted content is different, and IE and Opera are normal, firefox, Chrome, and Safari will not contract. The reason is that the scrollHeight value is equal to the text box height when the text box content height is smaller than the text
In javascript, the tab key in textarea is scaled down.
This example describes how to scale down the tab key in textarea using javascript. Share it with you for your reference. The details are as follows:
I searched for related solutions on the Internet. The other solutions were solved using two or three lines of
For those who write Javascript into the Web Editor, obtaining the cursor position in textarea is a very important issue. Many people are often at a loss and cannot find a good solution. Yesterday I found a piece of JavaScript on the Internet
Code I didn't want to put the original version here, because it was so wonderful that I was afraid that it would be broken
I recently wrote an online editor for UBB. Since the pop-up window is not used
Code At the end of textarea, I could not insert the cursor before, so I went online and went crazy to find information. I finally found out how to get the position in textarea, however, if textarea has a lot of content, it will flash. The Code is as follows.
Function getpos (OBJ){
Display the javascript code of the html page in textarea. I want to display the html page written in textarea as html.
I know that tools such as htmledit can't be used. I only need simple display.
1st Floor
You can use document. write ()
If you want to edit it, I think you may still need tools like htmledit. I am studying fckeditor, which has a few types and has
Javascript obtains the string in the textarea text box. If a carriage return or line break is contained,\ NInstead of what we usually see\ R \ n".
//If we want to obtain the carriage return Position entered by the user in textareaCode:VaRPos = content. indexof ("\ n ");//If we need to replace the carriage return with another character, such as a semicolon, we need to use code similar to the following:Con
Use javascript to dynamically assign TEXT data in the database to TEXTAREA. I want to dynamically add text data to TEXTAREA. The following programs cannot be properly displayed:
ShtForm is Form field, and Txt_CmpnyPrms is TEXTAREA
Response. Write ("
We often use JavaScript in web design to determine whether the user entered the legitimate data, if the user did not input data to give the corresponding prompts, then how to judge? Here we introduce the method of using JavaScript to judge whether the textarea value is empty.
The JavaScript functions are given below:
JavaScript implementation click to automatically select TextArea text Method
This example describes how to automatically select TextArea text by clicking JavaScript. Share it with you for your reference. The specific implementation method is as follows:
?
1 2 3 4
Readonly = "readonly"> Example t
Now popular Twitter and other micro-blogging sites, there is a good user experience, that is, in the text box input text, will automatically statistical input characters, and display the user can also enter the characters, in the limited 140 words in the micro-blog, such a small hint can be very good to enhance the user experience.If this technology is implemented, I did some research, found that the implementation is actually quite simple, a few lines of code can complete the input character st
The popular micro-blog websites such as Twitter have a good user experience. When you enter text in the text box, the entered characters are automatically counted, and display the characters that can be entered by the user. In a microblog with a limit of 140 characters, such tips can greatly enhance the user experience.If this technology is implemented, I did some research and found that the implementation is actually quite simple. After a few lines of code, I can complete the input character st
JavaScript gets the start position, end position, and selected text of the selected text in textarea .DemoHtml>The start position of the selected text,End Position andSelected text JavaScript gets the start position, end position, and selected text of the selected text in textarea
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.