contenteditable

Insert text in Javascript contenteditable div

Hi guys, I have a problem where I need to insert a text (string, may or may not have html tags) to a div. It has to be a div and not a textarea. Is there anyway to do that? First of all, I need to get the cursor position, then inserting the text in that position. It's similar to function insertAdjacentText, but it can only insert befo...

Firefox - designMode: disable image resizing handles

How can I prevent the user from being able to resize an image in designMode? (disable the handles when image is clicked) ...

Prevent line/paragraph breaks in contentEditable

When using contentEditable in Mozilla, is there a way to prevent the user from inserting paragraph or line breaks by pressing enter or shift+enter? ...

Why does contentEditable element reject the Enter key?

Hi, I'm using an application that embeds IE control to show content. I change that content to contain a <div contentEditable="True">Hello World</div> element. This works well and I can edit the content of this div, but pressing Enter is rejected with a beep. When I add a textarea element to that page the Enter key works and I can add l...

contentEditable on nodes in a XML/compound document?

I have an XML document that I'm displaying in a web browser, with a stylesheet attached: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml-stylesheet type="text/css" href="abc.css"?> <myxml xmlns:xhtml="http://www.w3.org/1999/xhtml"&gt; <para>I wish i was editable</para> <xhtml:script type="text/javascript" src="abc....

Why doesn't @contenteditable work on the iPhone?

Safari HTML Reference: Supported Attributes says: contenteditable If true, the element can be edited on the fly; if false, it cannot. Availability Available in Safari 1.2 and later. Available in iPhone OS 1.0 and later. However, on my iPhone, I can't get it to work. Anyone have success with this? You can try it ...

Keyboard events for child elements in a contenteditable div?

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...

jquery contenteditable linebreak

Hi Guys, I have a content editable area and im trying to disable enter/return and shift enter from creating a new paragraph, i have this working with the script below but it disables the buttoms all together, what i wish to do is have return just place a line break rather then go to a new paragraph. $("#content").keypress(function(e){ ...

Javascript - Change font color of certain text in textarea

Is there any JS function that can change the color of certain text in a textarea? For example, blar blar {blar} blar, {blar}, including { }, will be in blue. Other words will be in blank. In other words, all I need is a function that can change color of all text in { }. I've done some studies and it seems that most people say it can't ...

How to move cursor to end of contenteditable entity

Hi I need to move caret to end of 'contenteditable' node like on gmail notes widget i read threads on stackoverflow, but that solutions use input's and doesn't work with content editable ...

Problem detecting Newlines in JavaScript Range Object

I have some javascript that manipulates html based on what the user has selected. For real browsers the methods I'm using leverage the "Range" object, obtained as such: var sel = window.getSelection(); var range = sel.getRangeAt(0); var content = range.toString(); The content variable contains all the selected text, which ...

Set cursor position on contentEditable <div>

Hi There, I am after a definitive, cross-browser solution to set the cursor/caret position to the last known position when a contentEditable='on' <div> regains focus. It appears default functionality of a content editable div is to move the caret/cursor to the beginning of the text in the div each time you click on it, which is undesir...

How to make a DIV editable cross-browser ?

Do you know how to make a DIV editable with JavaScript (cross-browser) ? Something similar to a rich textarea, but that uses an editable iframe. I need something similar for a DIV. I don't want to use a replacement textbox. ...

How can I get the element the caret is in with Javascript, when using contentEditable?

Hi, Let's say I have some HTML code like this: <body contentEditable="true"> <h1>Some heading text here</h1> <p>Some text here</p> </body> Now the caret (the blinking cursor) is blinking inside the H1 element, let's say in the word "heading". How can I get the name of the element the caret is in with JavaScript? Here I would li...

return focus to contenteditable after execCommand?

Hi all, I have the following code demonstrating contenteditable property and a button that will inject bold text into the paragraph with contenteditable area. My question is how to return focus to where i left off after clicking on bold, if you highlight some text, and click bold, it'll bold those text, but the focus will not be there a...

contenteditable change events

I want to run a function when a user edits a contenteditable div. What's the equivalent of an onchange event? Thanks. I'm using jquery so any solutions that uses jquery is preferred. Thanks! ...

contenteditable and non button elements

I can easily do execcommand on a contenteditable selection if using a button. However using any other element fails. http://jsbin.com/atike/edit Why is this and how can I make it work using a div element. Thanks. ...

Is there any event between keypress and keyup in javascript?

I have a situation where I need to intercept every key thats being pressed in to a contentEditable div. But when the keypress event happens, if I do, document.getElementById("divEditor").innerHTML I cannot get the full text (does not have the last character pressed) Also, keyup event doesn't fire for continuous keypresses. What can I...

contentEditable breaks page up down buttons in firefox

Does anyone know how to fix (or what causes) the page up/down bug in FF when contentEditable is present on a div? See an example Navigate to contentEditable article with FireFox (3 or 3.5) and use the Page Up/down arrows on your keyboard. You should be unable to scroll to the bottom of the page, and it should appear to flicker and jump ...

Textarea contenteditable

I am trying to make a textarea content editable and I am failing. I am using this code: <textarea id='' class='' name='notes' rows='12' cols='67' contenteditable='true' ></textarea> I am expecting a result like http://html5demos.com/contenteditable Does anyone have an idea why it's not working? Edit: I am doing this because I am t...