Autor | Zpráva | ||
---|---|---|---|
Jupíí Profil |
#1 · Zasláno: 26. 5. 2008, 17:16:08
Ahoj mám tento script :
<p><input type="submit" name="tucne" value="B" onClick="document.frm.textarea.value=document.frm.textarea.value + '<b></b>'"> <input type="submit" name="tucne" value="U" onClick="document.frm.textarea.value=document.frm.textarea.value + '<u></u>'"> <form method="post" action="nahled.php" name="frm"> <textarea cols="100" rows="20" name="textarea"></textarea><br><br> <input type="submit" name="odeslat" value="Náhled"> </from> A já bych potřeboval že když by někdo do toho to okna něco napsal pak by si to označil a klikl by na B, tak by mu to bybraný text dalo mezi <b>Tady ten text </b>. Dá se to nějak udlělat? |
||
Chamurappi Profil |
#2 · Zasláno: 26. 5. 2008, 17:39:14
Reaguji na Jupíí:
Dá. Mrkni se třeba do zdrojáku této diskuse na JS funkci „insertTag“. |
||
Jupíí Profil |
#3 · Zasláno: 26. 5. 2008, 18:42:53
Chamurappi
Děkuji bude to asi tot že : function insertTag(aTag, eTag, input) { //var input = document.forms['formular'].elements['eingabe']; var bwr=new checkBrowser(); input.focus(); /* für Internet Explorer */ if(typeof document.selection != 'undefined') { /* Einfügen des Formatierungscodes */ var range = document.selection.createRange(); var insText = range.text; range.text = aTag + insText + eTag; /* Anpassen der Cursorposition */ range = document.selection.createRange(); if (insText.length == 0) { if(bwr.opr){ range.move('character', 0); }else{ range.move('character', -eTag.length); } } else { if(bwr.opr){ range.move('character', 0); }else{ range.moveStart('character', aTag.length + insText.length + eTag.length); } } range.select(); } /* für neuere auf Gecko basierende Browser */ else if(typeof input.selectionStart != 'undefined') { /* Einfügen des Formatierungscodes */ var start = input.selectionStart; var end = input.selectionEnd; var insText = input.value.substring(start, end); input.value = input.value.substr(0, start) + aTag + insText + eTag + input.value.substr(end); /* Anpassen der Cursorposition */ var pos; if (insText.length == 0) { pos = start + aTag.length; } else { pos = start + aTag.length + insText.length + eTag.length; } input.selectionStart = pos; input.selectionEnd = pos; } /* für die übrigen Browser */ else { /* Abfrage der Einfügeposition */ /* var pos; var re = new RegExp('^[0-9]{0,3}$'); while(!re.test(pos)) { pos = prompt("Einfügen an Position (0.." + input.value.length + "):", "0"); } if(pos > input.value.length) { pos = input.value.length; } /* Einfügen des Formatierungscodes */ /* var insText = prompt("Bitte geben Sie den zu formatierenden Text ein:"); input.value = input.value.substr(0, pos) + aTag + insText + eTag + input.value.substr(pos);*/ } } |
||
Jupíí Profil |
#4 · Zasláno: 26. 5. 2008, 19:08:16
Nemohl by min script někdo trochu vysvětlit? Moc mu nerozumím Prosím.
Předem děkuji |
||
Chamurappi Profil |
#5 · Zasláno: 26. 5. 2008, 19:26:14
Reaguji na Jupíí:
To je zvláštní druh skriptu, který se nevysvětluje, ale kopíruje. Proto jsou v něm také komentáře psané jakousi ošklivou evropskou hatmatilkou, i když běží na českém diskusním fóru. „Předem děkuji“ Nichts zu danken. Jestli umíš německy, zkus si přečíst originální popis. |
||
Jupíí Profil |
#6 · Zasláno: 26. 5. 2008, 21:23:05
Chamurappi
Něecky umím poměrně dobře |
||
Časová prodleva: 16 let
|
0