| Autor | Zpráva | ||
|---|---|---|---|
| BuGeR Profil |
#1 · Zasláno: 24. 4. 2010, 18:16:00
Zdraívm.
Chtěl bych se zeptat, da se nějak zjistit pomocí Javascriptu to, jaký text jsem označil v textaree? Např. mam v textaree napsáno "ABC" a označím myší "B" tak jak to "B" zjistit.. Hledal jsem na googlu ale bez výsledků.. Děkuji ;). |
||
| Beavis Profil |
#2 · Zasláno: 24. 4. 2010, 20:48:36
BuGeR:
Myslím že v JS tohle nejde. Zkus jQuery / AJAX. |
||
| Radek9 Profil |
#3 · Zasláno: 24. 4. 2010, 21:46:56 · Upravil/a: Radek9
Beavis:
„Myslím že v JS tohle nejde. Zkus jQuery / AJAX.“ Teď si trochu protiřečíš. AJAX i jQuery je JS. BuGeR: V jednom JS jsem měl tohle: function getTextareaSelection()
{
var textarea = document.forms["form"].elements["zprava"];
if (typeof textarea.selectionStart != 'undefined') {
var selection = textarea.value.substring(textarea.selectionStart, textarea.selectionEnd);
} else if (typeof document.selection != 'undefined') {
var selection = document.selection.createRange().text;
} else {
//alert('Bug!');
}
return selection;
} |
||
| fmedic Profil * |
#4 · Zasláno: 24. 4. 2010, 22:22:15
Beavis:
„Myslím že v JS tohle nejde. Zkus jQuery / AJAX.“ Zvláštní, že mně to v JS jde ;) var textarea = document.frm.text;
if (typeof textarea.selectionStart != 'efined') {
var selection = textarea.value.substring(textarea.selectionStart, textarea.selectionEnd);
var stringStart = textarea.selectionStart;
var stringEnd = textarea.selectionEnd;
predText = textarea.value.substring(0,stringStart);
var konec = document.frm.text.value.length;
zaText = textarea.value.substring(stringEnd, konec);
} else if (typeof document.selection != 'efined') {
var selection = document.selection.createRange().text;
} else {
//alert('Bug!');
} |
||
|
Časová prodleva: 16 let
|
|||
0