The Createrange method of selection
Document.selection.createRange () returns the TextRange object based on the current text selection, or returns the Controlrange object based on the control selection.
With execcommand, it is useful in the HTML editor, such as: Text bold, italic, copy, paste, create hyperlinks, and so on.
Example one:
The code is as follows
Copy Code
Ha ha. We are all freshmen. We all come to help each other. So that we can progress, we can make
Js implements the focus at the last position in the text box
This article mainly introduces the sample code that focuses on the final position in the js implementation text box. If you need it, you can refer to it for help.
In general programs, programmers generally like to determine the focus frame by determining the
); UpdateWindow ();Get button area can be used GetDlgItem (idc_time)->getclientrect (rect);Here are some other methods, but they are not very handy.GetDlgItem (idc_time)->getclientrect (rect);//inaccurateM_button. GetClientRect (rect);//Not sensitiveGetWindowRect (GetDlgItem (idc_time), rect);// GetDlgItem (idc_time)->getwindowrect (rect);//Gets the position of the control relative to the screenScreenToClient (rect);//convert to relative
Chipdlg is the idd_hip_dialog class.
Chipdlg * m_hipdlg; // define it first
M_hipdlg = new chipdlg (this );
M_hipdlg-> Create (idd_hip_dialog, this); // create dialog box
Crect rcdlgs;M_hipdlg-> getwindowrect (rcdlgs); // obtain the rect dialog box size.Screentoclient (rcdlgs); // convert the screen value to the actual value.
Int Cx = getsystemmetrics (sm_cxscreen); // obtain the screen re
This article mainly introduces the sample code that focuses on the final position in the js implementation text box. If you need it, you can refer to it and hope to help you in general programs. when detecting the content correctness in the input box, programmers generally like to determine the focus box by determining
. selectionStart | elem. selectionStart = '0') {// Firefox supportIndex = elem. selectionStart;}Return (index );}For ie browsers, the following code 1 is more convenient.
// Code 1If (document. selection ){Elem. focus ();Var Sel = document. selection. createRange ();Return {Left: Sel. boundingLeft,Top: Sel. boundingTop,Bottom: Sel. boundingTop + Sel. boundingHeight};}
Firefox and other browsers are simulated, as shown in. First, copy the style of the input area to a div layer (clone layer), then
When you do the page, you may use a fixed-position layer, read the DOCUMENT.BODY.SCROLLTOP to set the display floating box, like this:-DOCTYPE HTML>HTML> Head> MetaCharSet= "UTF-8"> title>Show floating box based on page scroll positiontitle> style>Body{Height:2000px;}#toTop{position:fixed;Bottom:100px; Right:0;Display:None; } style> Head> Body> Di
The mouse position and cursor position in the text box (textbox) is two different concepts, the mouse position is the key to click the Mouse (Nousedown) to obtain, and the cursor position is real-time to obtain, that is, the user input a character (KeyUp), this
Content inserted at the cursor position in the text box is often used in actual project applications. For example, to insert an expression in the text box, you must first obtain the position of the cursor in the text box. Of course, there is a browser compatibility problem.
In a general program. When the programmer makes the content correctness of the input box, it usually likes to determine the focus box by judging the legality of the content.
Such as:
Copy Code code as follows:
if (obj.value== "") {
Obj.focus ();
return false;
}
This moves the focus to the input box when the input
Obtain the div editing box, textarea, and inputtext. The cursor position is compatible with the IE, FF, and Chrome methods. If you have any need, you can refer to the online solution for 2 hours, but it is not compatible with FF, it seems that this kind of thing is not ready for use on the Internet.
Now released, there will be ready-made online for people to use.
In order to save trouble, it is also very c
This article mainly introduces the focus position in the js setting text box in the final sample code. If you need it, you can refer to it and hope to help you directly use this in Firefox. focus.
In IE, the text box value is assigned to the text box after this. focus. It's easy !!
For example:
The Code is as fol
The Code TextRange that uses TextRange to obtain the cursor position in the input box is an object used to represent text in HTML elements. Although this object is not commonly used, it is provided in IE4.0. However, the call methods provided by TextRange are obscure, so what can we do with it?
The traditional use of TextRange is to circle text content on web pages, such as changes, deletions, and addition
This phenomenon only occurs in the wp8.1 program of the sencha touch package in phonegap (only wp8.1, wp8 is normal). I tested several other js frameworks (app framework, jquery mobile ), it seems that there is no such problem.
Let me describe this phenomenon:
1. Run the wp8 program packaged by phonegap to open an interface with an input box, such:
2. Click the input box to bring up the keyboard. The int
A more convenient and concise operation is:
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->
Textboxmsg. appendtext (datetime. Now. tostring (
"
Yyyy-mm-dd hh: mm: Ss. fff
"
)
+
"
:
"
+
MSG
+
"
\ R \ n
"
);
//////////////////////////////////////// //////////////////////////////////////// /////////////////
In the past, I wrote another complex method:
Code highlighting produced by Actipro CodeHi
XHTML parsing when Dd.scrolltop is 0 varSt=(Dd.scrolltop||db.scrolltop), C; C=St-O.offsettop+(p.t!=undefined?p.t: (W.innerheight||dd.clientheight)-o.offsetheight); if(c!=0) {O.style.top=O.offsettop+Math.ceil (Math.Abs (c)/* (c }Else{clearinterval (timer); } },Ten}}}}} Scrollx ({ID:'AA', T: -, }) /*ID you want to scroll the contents of the ID l the position of the horizontal axis is not written as close to the right t you want t
TextRange is an object used to express text in HTML elements. Although we do not usually use this object, it is provided in IE4.0. However, the call methods provided by TextRange are obscure, so what can we do with it?The traditional use of TextRange is to circle text content on web pages, such as changes, deletions, and additions. However, its classic purpose is to search for text on the Web page (which is relatively simple) and obtain the cursor position
Lt ;! DOCTYPEhtmlPUBLIC quot;-// W3C // DTDXHTML1.0Transitional // EN quot; http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtdquot;gt;
Js to get the position of the cursor in the text box (text/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.