![]() |
Show 150 posts per page |
.dsy:it. (http://www.dsy.it/forum/)
- Tech (http://www.dsy.it/forum/forumdisplay.php?forumid=189)
-- [Javascript] (http://www.dsy.it/forum/showthread.php?threadid=22209)
[Javascript]
Ciao a tutti...
Dovrei fare una cosa del genere:
- Inserire un testo in una textarea
- Selezionare parte del testo
- A questo testo selezionato aggiungere all'inizio e alla fine una @ premendo un bottone.
Fino al bottone ci arrivo, al click faccio eseguire una funzione, ma le @ vengono messe alla fine della textarea...
Come fare per metterle all'inizio e alla fine del testo *selezionato* ???
__________________
Napolux.com
scusa, io non so darti una risposta... ma non riesci a dare un occhiata a come funzionano le form dei forum (oviamente quelli che te lo permettono)???
è un'idea... scusa se non è la risposta che cercavi...
__________________
http://www.twitter.com/0m4r
Ho usato un pò javascript qualche tempo fa e per quel che mi ricordo non mi sembra una cosa fattibile, poichè credo che la selezione del testo sia esterna a javascript stesso, ma gestita dall'interfaccia grafica.
Nessuna garanzia però 
__________________
?
Originally posted by 0m4r
scusa, io non so darti una risposta... ma non riesci a dare un occhiata a come funzionano le form dei forum (oviamente quelli che te lo permettono)???
è un'idea... scusa se non è la risposta che cercavi...
__________________
Napolux.com
Io lo so fare con IE, ma purtroppo non conosco il modello selection di Firefox, quindi dubito che ti sia utile...
__________________
«And if you ever smell christian blood up in the mountains, then get your axe and chop them down!»
Originally posted by ripe
Io lo so fare con IE, ma purtroppo non conosco il modello selection di Firefox, quindi dubito che ti sia utile...
__________________
Napolux.com
Ok, allora il codice - scritto in maniera moooolto sporca
- è semplicemente questo:
code:
<script> function marcaSelezione() { var selezione = document.selection.createRange().text; if (selezione != "") document.selection.createRange().text = "@" + selezione + "@"; } </script> <input type="button" onClick="marcaSelezione()" value="Inserisci" /><br /> <textarea>Testo da selezionare</textarea>
__________________
«And if you ever smell christian blood up in the mountains, then get your axe and chop them down!»
Più che il modello di Mozilla direi il DOM standard... o sbaglio?
__________________
Bjarne Stroustrup: "I have always wished for my computer to be as easy to use as my telephone; my wish has come true because I can no longer figure out how to use my telephone."
Andrew S. Tanenbaum: "Never underestimate the bandwidth of a station wagon full of tapes hurtling down the highway."
Edsger Dijkstra: "Computer Science is no more about computers than astronomy is about telescopes."
Robert Firth: "One of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs."
Donald Knuth: "A mathematical formula should never be 'owned' by anybody! Mathematics belong to God."
Originally posted by Hamelin
Più che il modello di Mozilla direi il DOM standard... o sbaglio?

__________________
«And if you ever smell christian blood up in the mountains, then get your axe and chop them down!»
deng iu!
__________________
Napolux.com
| All times are GMT. The time now is 22:56. | Show all 10 posts from this thread on one page |
Powered by: vBulletin Version 2.3.1
Copyright © Jelsoft Enterprises Limited 2000 - 2002.