Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Cytuj zaznaczony tekst, jak zrobić coś takiego?
yasiek
post
Post #1





Grupa: Zarejestrowani
Postów: 59
Pomógł: 0
Dołączył: 4.06.2006
Skąd: Strzeszyce/Kraków

Ostrzeżenie: (0%)
-----


Witajcie smile.gif
Chciałbym dodać taką funkcję na forum... ale totalnie nie wiem od której strony to ugryźć... mam już banalną funkcję od znaczników/emotikon, która prezentuje się mniej więcej tak:
  1. function emot(e){
  2. document.formularz.komentarz.value+=e;
  3. document.formularz.komentarz.focus();
  4. }


Da się to jakoś tak przerobić, żeby dodawało do tego samego okna zaznaczony tekst?

stworzyłem coś takiego:
  1. var txt = '';
  2. if (window.getSelection) //mozilla safari
  3. {
  4. txt = window.getSelection();
  5. }
  6. else if (document.getSelection) //mozilla opera
  7. {
  8. txt = document.getSelection();
  9. }
  10. else if (document.selection) //tylko ie
  11. {
  12. txt = document.selection.createRange().text;
  13. }
  14. else return;
  15. //kod który obrabia wybrany tekst
  16. document.forumform.message.value += '[ quote ]'+txt+'[ /quote ]\n';
  17. document.forumform.message.focus();
  18. }

ale nie chce działać...

Ten post edytował yasiek 3.09.2006, 17:18:58
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 1)
Kirtan Loor
post
Post #2





Grupa: Zarejestrowani
Postów: 44
Pomógł: 0
Dołączył: 22.10.2004
Skąd: Płock

Ostrzeżenie: (0%)
-----


  1. var txtarea = document.getElementById('id');
  2.  
  3. var selStart = txtarea.selectionStart;
  4. var selEnd = txtarea.selectionEnd;
  5.  
  6. var quote = txtarea.value.substring(selStart, selEnd);
  7.  
  8. return quote;


--------------------
A Chartreux et à Célestins, A Mendiants et à Dévotes,
A musards et claquepatins, A servants et filles mignottes
Portants surcots et justes cottes,A cuidereaux d'amour transis,
Chaussant sans méhaing fauves bottes, Je crie à toutes gens mercis.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 20.08.2025 - 15:56