contenteditable

How can I create an html input text area such that I can underline or format certain words?

为君一笑 提交于 2019-12-20 03:55:08
问题 I'd like an input field that I can have javascript set certain attributes for, for different parts of the input field. A simple example to demonstrate what I'd like to do: let's say I want to underline all curse words in an input text area. So the javascript would check the input text area when a new letter is inserted, and for any words matching my array of recognized curse words, it would underline the word. Note, I do not want the user/client to be able to set any attributes of the text, I

How to get value contentEditable in PHP

半城伤御伤魂 提交于 2019-12-20 03:00:36
问题 How we can get the content present in contentEditable in html format in PHP For example i have this code and want to get its value in a variable in PHP: <div contentEditable="true"> type here <img src="http://t2.gstatic.com/images?q=tbn:ANd9GcQCze-mfukcuvzKk7Ilj2zQ0CS6PbOkq7ZhRInnNd1Yz3TQzU4e&t=1" /></div> ​ because i want to use this as html body for an email. Infact i want to get the value of contentEditable and save it into a variable and then use that variable as a body for my email. Any

Keyboard events for child elements in a contenteditable div?

冷暖自知 提交于 2019-12-19 19:53:26
问题 I have a div who's contenteditable property has been set to true.How do I get the children to respond to keyboard events? Seems like the only way is to capture the events in the parent div and figure out the child via the selection apis. Is there a better way? More specifically, can I attach a keyboard event handler to child elements? Am I missing something? Attached is sample code that illustrates the problem. Hope the in-code comments are sufficiently explanatory. <HTML> <HEAD> <TITLE><

IE input event for contenteditable?

心已入冬 提交于 2019-12-19 17:24:59
问题 I am wondering if there is a polyfill to support the contenteditable input event in IE11 ? I am specifically talking about this event: http://jsfiddle.net/ch6yn/ Which fires whenever a change happens on a contenteditable div regardless of the source (e.g. copy/paste/drag/drop/type etc). <div contenteditable="true" id="editor">Please type something in here</div> <script> document.getElementById("editor").addEventListener("input", function() { alert("input event fired"); }, false); </script>

Turn off grammar correction in a contenteditable div in FireFox

六眼飞鱼酱① 提交于 2019-12-19 15:14:08
问题 I have contenteditable div with text on it. In firefox, there is some kind of grammar correction which underlines the text with red marking. How can I turn it off? How do I turn off the red markings in FireFox? <div contenteditable ='true'>Why do you underline me?</div> JSFiddle: http://jsfiddle.net/26JkW/ 回答1: There is no grammar-checking native to Firefox. Given that every word is being marked as incorrect, it is possible that you have the wrong language selected. To verify that you have

Retain cursor position in contenteditable

£可爱£侵袭症+ 提交于 2019-12-19 10:23:21
问题 I am trying to create a richtext area using contenteditable. The parser for the highlighting returns a html string which I replace the content of the element with (perhaps ineffective, thats the way it has to be for now). The problem with contenteditable is that the cursor position is not retained after something like this, which I can understand. Is there a way to retain this position? I could make the parser return a element representing where the caret should be (given the cursors offset

How do I get the element being edited?

时光总嘲笑我的痴心妄想 提交于 2019-12-19 05:09:06
问题 I'm developing a webapp, and I have a problem with the JavaScript. The following is a simplified version of the HTML causing the problem. I have some nested contenteditable divs (I replaced the real content with placeholder text): <div contenteditable="true" id="div1"> text <div contenteditable="inherit" id="div2"> text <div contenteditable="inherit" id="div3"> text </div> text </div> text </div> I want to get the element that's selected (being edited by the user) via JavaScript, but so far I

Paste as plain text Contenteditable div & textarea (word/excel…)

拈花ヽ惹草 提交于 2019-12-18 13:31:43
问题 I would like the to paste text in a contenteditable div, but reacting as a textarea. Note that I want to keep the formatting as I would paste it in my textarea (from word, excel...). So. 1) Paste text in contenteditable div 2) I get the text from clipboard 3) I push my value from clipboard to my textarea, (dont know how??) 4) Get value from my textarea and place it in my contenteditable div Any suggestions? 回答1: I'm CKEditor's core developer and by coincidence for last 4 months I was working

What are the cons of using a contentEditable div rather than a textarea?

痞子三分冷 提交于 2019-12-18 12:45:13
问题 Would I be shooting myself in the foot by using a div with attribute contentEditable="true" as a text field rather than a textarea? 回答1: It would work fine, but it'd be a little bit more difficult than a form, simply because you're going to have to wire up your own logic to make the button's click event track down the correct div, get its content, and then perform the submission. The advantage of a textarea is that the browser takes care of all that for you. 回答2: It's not the same thing.

How to edit a link within a contentEditable div

家住魔仙堡 提交于 2019-12-18 11:39:09
问题 Does anyone have any suggestions on how to edit an link in a contentEditable div? It would be ideal once the link is either clicked with mouse, or the cursor hits the link, that the a small prompt would pop up and allow the user to change the href property of the link. The prompt isn't the issue, but how is it possible to detect the link has been either clicked or that the cursor has arrived at the link? onfocus doesn't seem to work in a contentEditable div on Firefox & Safari. Any ideas? 回答1