selectionStart and selectionEnd in contenteditable element

Try this, it returns the selected text, no matter if it’s contentEditable or not. function GetSelectedText() { if (document.getSelection) { // all browsers, except IE before version 9 var sel = document.getSelection(); // sel is a string in Firefox and Opera, // and a selectionRange object in Google Chrome, Safari and IE from version 9 … Read more

HTML : Is there any way to show images in a textarea?

Use a div with contentEditable attribute which acts like a textarea. That’s how wysiwyg editors are created. div { width: 300px; height: 200px; border: 1px solid #ccc; } <div contentEditable=”true”>Type here. You can insert images too <img src=”http://t2.gstatic.com/images?q=tbn:ANd9GcQCze-mfukcuvzKk7Ilj2zQ0CS6PbOkq7ZhRInnNd1Yz3TQzU4e&t=1″ /> </div>

New Line in Textarea to be converted to

This will replace line breaks to HTML break tags. The different combinations are to cover the different browsers/systems and how line breaks are interpreted. $(this).val().replace(/\r\n|\r|\n/g,”<br />”) This will bring it back to new lines – also covering how different browsers interpret innerHTML. boxText.replace(/<br\s?\/?>/g,”\n”);

I am using tinymce, Is it possible to apply for only one textarea

For the textarea assign a class=”” to textarea property, this will support for you <script type=”text/javascript”> tinyMCE.init({ //mode : “textareas”, mode : “specific_textareas”, editor_selector : “myTextEditor”, theme : “simple” }); </script> <textarea id=”txtdesc” name=”txtdesc” class=”myTextEditor” rows=”6″ cols=”96″ ></textarea>

Limiting number of lines in textarea

This might help (probably be best using jQuery, onDomReady and unobtrusively adding the keydown event to the textarea) but tested in IE7 and FF3: <html> <head><title>Test</title></head> <body> <script type=”text/javascript”> var keynum, lines = 1; function limitLines(obj, e) { // IE if(window.event) { keynum = e.keyCode; // Netscape/Firefox/Opera } else if(e.which) { keynum = e.which; } … Read more