textselection

Can you set and/or change the user’s text selection in JavaScript?

故事扮演 提交于 2019-11-26 22:44:37
In JavaScript, there are various methods for accessing the user’s text selection, and creating text selections (or ranges) — see http://www.quirksmode.org/dom/range_intro.html . As per that page, you can programmatically create a range, and access the text within that. But doing this doesn’t change the user’s text selection, or make the user have some selected text if they don’t already. Can you set and/or change the user’s text selection in JavaScript? Yes. In all browsers you can get one or more Range s or a TextRange from the user's selection, and both Range and TextRange have methods for

Why does the CSS3 pseudo ::selection not change the color for all parts?

陌路散爱 提交于 2019-11-26 21:37:53
问题 Why does the CSS3 pseudo-element selection not change all parts of the highlight? As you can see in this screenshot I have selected part of the page, and parts of the selection are the default bright blue color: This is the CSS that I'm using, it is at the top of my CSS file: ::selection { background: #3B3B3B; color: #fff; } ::-moz-selection { background: #3B3B3B; color: #fff; } It seems like the highlight for inputs (text, checkboxes, etc.) and white space does not change. Does anyone know

How to override default text selection of android webview os 4.1+?

谁都会走 提交于 2019-11-26 19:14:50
问题 Before posting this question I've searched a lot but could not find any clear answers on this issue. I have to override default text selection of android webview & show my custom text selection dialog options. I have tried this sample code project. This sample project works on following devices & emulator : Acer Iconia a500 tablet : 10 inch : Android OS - 3.0 Acer Iconia a500 tablet : 10 inch : Android OS - 3.2 Samsung Galaxy Tab : 10 inch : Android OS - 4.0 Samsung Galaxy Tab : 7 inch :

How do I disable text selection with CSS or JavaScript? [duplicate]

感情迁移 提交于 2019-11-26 17:53:26
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: CSS rule to disable text selection highlighting I am making a HTML/CSS/jQuery gallery, with several pages. I indeed have a "next" button, which is a simple link with a jQuery click listener. The problem is that if the user click the button several times, the text of the button is selected, and then the full line of text. In my really darky design, that is really ugly and nonsensical. So here is my question: Can

Return HTML from a user-selected text

那年仲夏 提交于 2019-11-26 17:27:07
I have the following, very simple html page: <html> <head> <script type="text/javascript"> function alertSelection() { var selection = window.getSelection(); var txt = selection.toString(); alert(txt); } </script> </head> <body> This is <span style="background-color:black;color:white">the</span> text. <div style="background-color:green;width:30px;height:30px;margin:30px" onmouseover="alertSelection()"> </body> </html> When I select the entire first line and mouseover the square, I get an alert with "This is the text.". How would I fix this so the the span tag or any other selected HTML isn't

Disabling text selection in PhoneGap

可紊 提交于 2019-11-26 15:37:46
问题 Is it possible to disable text selection to make a PhoneGap app more similar to normal native app? Something like this: document.onselectstart = function() {return false;} or: * { user-select: none; -moz-user-select: -moz-none; -khtml-user-select: none; -webkit-user-select: none; } Or many other things don't work. 回答1: I looked all over for help on this. This finally worked for me. public class MainActivity extends DroidGap { @Override public void onCreate(Bundle savedInstanceState) { super

set cursor to specific position on specific line in a textarea

南笙酒味 提交于 2019-11-26 14:48:56
问题 I am trying to somewhat duplicate the "autocorrect" functionality seen in programs like Microsoft Office's Outlook. For starters, anytime a user types "a " (the letter a and a space) at the beginning of a line I want to change that text to "*Agent [" I have written the below which works fine if you are typing along in the textarea from top to bottom. But if you type anywhere else in the textarea the text is changed then the cursor moves to the end of the textarea. I want the cursor to always

Can I select a specific block of text in a UITextField?

蓝咒 提交于 2019-11-26 08:29:38
问题 I have a UITextField in my iPhone app. I know how to make the text field select all of its text, but how can change the selection? Say I wanted to select the last 5 characters, or a specific range of characters, is that possible? if not, can I move the lines marking the beginning and end of the selection, as if the user is dragging them? 回答1: With UITextField, you cannot. But if you see the headers, you have _selectedRange and others that might be used if you add some categories to it ;)

Can you set and/or change the user’s text selection in JavaScript?

白昼怎懂夜的黑 提交于 2019-11-26 08:25:35
问题 In JavaScript, there are various methods for accessing the user’s text selection, and creating text selections (or ranges) — see http://www.quirksmode.org/dom/range_intro.html. As per that page, you can programmatically create a range, and access the text within that. But doing this doesn’t change the user’s text selection, or make the user have some selected text if they don’t already. Can you set and/or change the user’s text selection in JavaScript? 回答1: Yes. In all browsers you can get

Return HTML from a user-selected text

坚强是说给别人听的谎言 提交于 2019-11-26 05:25:10
问题 I have the following, very simple html page: <html> <head> <script type=\"text/javascript\"> function alertSelection() { var selection = window.getSelection(); var txt = selection.toString(); alert(txt); } </script> </head> <body> This is <span style=\"background-color:black;color:white\">the</span> text. <div style=\"background-color:green;width:30px;height:30px;margin:30px\" onmouseover=\"alertSelection()\"> </body> </html> When I select the entire first line and mouseover the square, I get