![]() |
![]() ![]() |
![]() |
![]()
Post
#1
|
|
![]() Grupa: Zarejestrowani Postów: 26 Pomógł: 0 Dołączył: 17.02.2005 Skąd: skad Ostrzeżenie: (0%) ![]() ![]() |
Nie moge rozwiazac problemu z funkcja w JS ktora po zaznaczeniu czesci tekstu w polu i nacisnieciu przycisku wykonywujacego funkcje obejmywalaby ten tekst w tagi np . Tak jak jest tutaj na tym forum w dodawaniu postow. Bardzo tego potrzebuje. Z gory dzieki
|
|
|
![]()
Post
#2
|
|
![]() Grupa: Przyjaciele php.pl Postów: 2 258 Pomógł: 16 Dołączył: 21.09.2004 Skąd: Kielce Ostrzeżenie: (0%) ![]() ![]() |
Link: http://www.webgurusforum.com/8/12/0
Lekka modyfikacja: Kod <script type="text/javascript"> function Bold() { var txtarea = document.getElementById("area"); var selStart = txtarea.selectionStart; var selEnd = txtarea.selectionEnd; document.getElementById("area").value= (txtarea.value).substring(0,selStart)+ "[B]"+(txtarea.value).substring(selStart, selEnd)+"[/B]" + (txtarea.value).substring(selEnd,txtarea.value.length); } </script> Pięknie to nie wygląda, ale robi to co chcesz ![]() -------------------- -------------
------ |
|
|
![]()
Post
#3
|
|
![]() Grupa: Zarejestrowani Postów: 26 Pomógł: 0 Dołączył: 17.02.2005 Skąd: skad Ostrzeżenie: (0%) ![]() ![]() |
Działa i wygląda pieknie
![]() Upgrade'owalem troszeczke te funkcje. Kod function Bold() { var txtarea = document.getElementById("wpis"); var selStart = txtarea.selectionStart; var selEnd = txtarea.selectionEnd; var length = ((txtarea.value).substring(selStart, selEnd)).length; var b = document.getElementById("b").value; if (length >= 1) { document.getElementById("wpis").value = (txtarea.value).substring(0,selStart) + "[B]" + (txtarea.value).substring(selStart, selEnd) + "[/B]" + (txtarea.value).substring(selEnd,txtarea.value.length); } else { if (b == "B") { document.getElementById("b").value = "B *"; document.getElementById("wpis").value = (txtarea.value).substring(0,selStart) + "[B]" + (txtarea.value).substring(selEnd,txtarea.value.length); } else if (b == "B *") { document.getElementById("b").value = "B"; document.getElementById("wpis").value = (txtarea.value).substring(0,selStart) + "[/B]" + (txtarea.value).substring(selEnd,txtarea.value.length); } } document.getElementById("wpis").focus(); }
To dla takich jak ja zeby nie musieli juz szukac i pisac postow od niechcenia. //edit PILNE!! Czy ktos jest w stanie (ktos na pewno) dodac jeszcze w powyzszym skrypcie obsluge dla IE. Chodzi tu glownie o znajdowanie miejsca rozpoczecia i konca zaznaczenia. Problem jest tylko z IE. Probowalem TextRange() i createTextRange() ale za nic nie kumam jak znalezc ten poczatek i koniec ![]() Ten post edytował senor_d 5.02.2006, 18:53:19 |
|
|
![]() ![]() |
![]() |
Aktualny czas: 21.08.2025 - 05:18 |