JS Quicktags


I’ve released the JavaScript Quicktags used in Tasks Pro™, Tasks and WordPress under the LGPL license.

This is a set of buttons that allow you to insert HTML tags into a content area. The tags are cursor aware – placed around a selection or at the cursor position. This is also an example of how to get the cursor position with JavaScript.


Example Page


A sample insertAtCursor function:


function insertAtCursor(myField, myValue) {
//IE support
if (document.selection) {
myField.focus();
sel = document.selection.createRange();
sel.text = myValue;
}
//MOZILLA/NETSCAPE support
else if (myField.selectionStart || myField.selectionStart == '0') {
var startPos = myField.selectionStart;
var endPos = myField.selectionEnd;
myField.value = myField.value.substring(0, startPos)
+ myValue
+ myField.value.substring(endPos, myField.value.length);
} else {
myField.value += myValue;
}
}

// calling the function

insertAtCursor(document.formName.fieldName, 'this value');









JS Quicktags : alexking.org: JS Quicktags






0 comments:

Luncurkan toko Anda hanya dalam 4 detik dengan 
 
Top