![]() |
![]() |
![]()
Post
#1
|
|
![]() Grupa: Zarejestrowani Postów: 521 Pomógł: 0 Dołączył: 3.11.2003 Skąd: 3city Ostrzeżenie: (0%) ![]() ![]() |
Czy istnieje sposób na sprawdzenie, jaka jest pozycja kursora w polu <textarea> ? Funkcja musiałaby zwracać liczbę - numer znaku po którym znajduje się kursor. Dodam że miałoby to chodzić nie tylko pod IE, ale też pod Mozillą.
Swoją drogą, takie coś przydałoby się nam chociażby na forum, żeby emotki nie wstawiały się zawsze na koniec posta. |
|
|
![]() |
![]()
Post
#2
|
|
![]() Grupa: Przyjaciele php.pl Postów: 554 Pomógł: 0 Dołączył: 4.04.2002 Skąd: Tychy Ostrzeżenie: (0%) ![]() ![]() |
Wlasnie tego pol dnia szukam i postanowilem w koncu spytac na forum. Widze jednak ze nikt nie zna odpowiedzi
![]() W phpbb costam kombinowali z zaznaczonym textem no ale Cytat if ((clientVer >= 4) && is_ie && is_win) mówi samo za siebie :/ -------------------- "Real children don't go hoppity-skip unless they are on drugs."
|
|
|
![]()
Post
#3
|
|
Grupa: Zarejestrowani Postów: 90 Pomógł: 0 Dołączył: 3.04.2003 Skąd: Opole Ostrzeżenie: (0%) ![]() ![]() |
Kod <html> <head> <script type="text/javascript"> 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'); </script> </head> <body> <form name="a"> <textarea id="b" cols="50" rows="5">Some text .. Some text .. Some text .. Some text .. Some text .. Some text .. Some text .. Some text .. Some text .. Some text .. Some text .. Some text .. Some text .. Some text .. Some text .. Some text .. </textarea> </form> <input type="text" value=" !cos! " id="cos"><a href="javascript:void(0)" id="b" onclick="insertAtCursor(document.a.b, document.getElementById('cos').value);">Wstaw</a> </body> </html> Dziala na IE i Mozilli, na Operze nie google rox ![]() -------------------- code.gosu.pl
|
|
|
![]() ![]() |
![]() |
Aktualny czas: 19.08.2025 - 18:42 |