textselection

How to make HTML Text unselectable [duplicate]

浪尽此生 提交于 2019-11-26 04:34:21
问题 This question already has an answer here: How to disable text selection highlighting 43 answers I would like to add text to my webpage as a label and make it unselectable. In other words, When the mouse cursor is over the text I would like it to not turn into a text selecting cursor at all. A good example of what I\'m trying to achieve is the buttons on this website (Questions,Tags,Users,...) 回答1: You can't do this with plain vanilla HTML, so JSF can't do much for you here as well. If you're

Coordinates of selected text in browser page

淺唱寂寞╮ 提交于 2019-11-26 02:35:45
问题 I need the coordinates in pixels of the beginning of the text selection (anywhere on the page, not in a textarea). I tried using the cursor coordinates but this didn\'t work quite well because the cursor coordinates and the beginning of the selection are not always the same (for example when a user drags over a text). I hope someone has the solution! 回答1: In IE >= 9 and non-IE browsers (Firefox 4+, WebKit browsers released since early 2009, Opera 11, maybe earlier), you can use the

Is there a way to make text unselectable on an HTML page? [duplicate]

一世执手 提交于 2019-11-26 00:46:54
问题 This question already has answers here : How to disable text selection highlighting (43 answers) Closed 6 years ago . I\'m building an HTML UI with some text elements, such as tab names, which look bad when selected. Unfortunately, it\'s very easy for a user to double-click a tab name, which selects it by default in many browsers. I might be able to solve this with a JavaScript trick (I\'d like to see those answers, too) -- but I\'m really hoping there\'s something in CSS/HTML directly that

How to get selected text from textbox control with javascript

元气小坏坏 提交于 2019-11-26 00:28:33
问题 I have a textbox and a link button. When I write some text, then select some of them and then click the link button, selected text from textbox must be show with a messagebox. How can I do it? When I click the submit button for textbox below, message box must show Lorem ipsum. Because \"Lorem ipsum\" is selected in the area. If I select any text from the page and click the submit button it is working, but if I write a text to textbox and make it, it\'s not. Because when i click to another

How to disable text selection highlighting

大城市里の小女人 提交于 2019-11-25 22:13:05
问题 For anchors that act like buttons (for example, Questions , Tags , Users , etc. at the top of the Stack Overflow page) or tabs, is there a CSS standard way to disable the highlighting effect if the user accidentally selects the text? I realize this could be done with JavaScript, and a little googling yielded the Mozilla-only -moz-user-select option. Is there a standard-compliant way to accomplish this with CSS, and if not, what is the \"best practice\" approach? 回答1: UPDATE January, 2017:

Get the Highlighted/Selected text

送分小仙女□ 提交于 2019-11-25 21:44:43
问题 Is it possible to get the highlighted text in a paragraph of a website e.g. by using jQuery? 回答1: Getting the text the user has selected is relatively simple. There's no benefit to be gained by involving jQuery since you need nothing other than the window and document objects. function getSelectionText() { var text = ""; if (window.getSelection) { text = window.getSelection().toString(); } else if (document.selection && document.selection.type != "Control") { text = document.selection