PHP-Nukefordonkeys.com - News - Manuali - Versione JS della funzione Trim() del VBScript
. ::  7 Temi gratuiti 100% Css/xHtml  ::  NukeSentinel(tm) 2.6.00  ::  Defacciati i siti ICANN e IANA  ::  Il tuo sito nella Storia PHPNuke!  ::  Estate e Sicurezza ::.
Benvenuto su PHP-Nukefordonkeys.com Donkeys76 Mercatino 1200Temi Manuale
 
Benvenuto su PHP-Nukefordonkeys.com

  Iscriviti! E' Gratis!                                                                                                   
La Tua WebAgency


Menu Generale
Home
News
Mappa del Sito
Recensioni
Trova Tutto
Utenti
Forums
Downloads
Contatti
Promo Tuo Sito
Tutorials
Speciali
Manuali
PHPNuke Tools
Utility
Gallerie
Nuke Shopping
Documenti

Recensioni Siti
·MemHT.com
·Corvoingordo.com

MySQL Facile

**************
·Ricette cucina Gratis
·Investire Forex
·Prestiti Mutuo
·Dieta personalizzata
·casino online
·Torrents
·Sfrutta meglio il web
·Guida casino online
·Prestito auto




NEWS

 Leggi News  Invia News  Argomenti  Archivio Articoli  Ritorno al Futuro

Manuali

News: Versione JS della funzione Trim() del VBScript
Stampa Stampa Invia Invia Mobile Mobile

La funzione Trim() è un gioiellino proprietario del VBScript che serve ad eliminare spazi vuoti all'inizio ed alla fine di una stringa. Purtroppo il Javascript non ne è nativamente dotato, ma per il principio che nulla si crea e nulla si distrugge, tutto si trasforma (forse non c'entra nulla, ma fa figo dirlo!) la funzione Trim() ce la creiamo noi...

Di seguito il codice abbondantemente commentato, pronto per l'utilizzo immediato:


function Trim(StrToTrim)
{
// CONTROLLA CHE IL VALORE IN INPUT SIA DI TIPO STRING
if (typeof StrToTrim != "string")
{
return StrToTrim;
}

// CATTURA IL PRIMO CARATTERE DELLA STRINGA
// PER CONTROLLARE CHE NON SIA UNO SPAZIO VUOTO
var StrBlank = StrToTrim.substring(0, 1);

// ELIMINA LO SPAZIO VUOTO DALLA PRIMA POSIZIONE DELLA STRINGA
while (StrBlank == " ")
{
StrToTrim = StrToTrim.substring(1, StrToTrim.length);
StrBlank = StrToTrim.substring(0, 1);
}

// CATTURA L'ULTIMO CARATTERE DELLA STRINGA
// PER CONTROLLARE CHE NON SIA UNO SPAZIO VUOTO
StrBlank = StrToTrim.substring(StrToTrim.length - 1, StrToTrim.length);

// ELIMINA LO SPAZIO VUOTO DALL'ULTIMA POSIZIONE DELLA STRINGA
while (StrBlank == " ")
{
StrToTrim = StrToTrim.substring(0, StrToTrim.length-1);
StrBlank = StrToTrim.substring(StrToTrim.length-1, StrToTrim.length);
}

// ELIMINA POTENZIALI SPAZI VUOTI MULTIPLI
// ALL'INIZIO ED ALLA FINE DI UNA STRINGA
while (StrToTrim.indexOf("") != -1)
{
StrToTrim = StrToTrim.substring(0, StrToTrim.indexOf(""));
StrToTrim += StrToTrim.substring(StrToTrim.indexOf("") + 1, StrToTrim.length);
}

// RESTITUISCE IL VALORE FINALE SENZA SPAZI VUOTI DI CONTORNO
return StrToTrim;
}


Di seguito ecco come si può richiamare la nostra funzione Trim() da un'altra applicazione Javascript:


document.write(Trim(" lukeonweb "));


Il risultato sarà la stringa lukeonweb priva degli spazi vuoti iniziali e finali.


(Cherek - Venerdì, 23 aprile ore 23,04 )

Articolo...........................News: Versione JS della funzione Trim() del VBScript
Login/Crea AccountCommenti ricevuti..........0 commenti

Vuoi commentare questo articolo?
Puoi lasciare un tuo commento su questo articolo cliccando sul bottone qui sotto. I commenti sono di proprietà dell'inserzionista pertanto decliniamo ogni responsabilità per il loro contenuto.



Commenti NON Abilitati per gli Anonimi, registrati



 
Links Correlati
· Altro su: Manuali
· News by rinok


Articolo più letto relativo a Manuali:
Rilasciato il Romanzo di Nuke e Donkey


Votazione Articolo
Media Punteggio: 0
Voti: 0

Per favore vota
per questo articolo:

Eccellente
Ottimo
Buono
Normale
Scarso





^ torna su ^


Scopri come ricevere gratuitamente sul tuo cellulare le nostre news




Siti consigliati: Webisland - Weblord - Tiempolibresite - jugo - Sfondi Gratuiti - pcprimipassi - aliek - tweakness - Script e Manuali - net-free - Manuali - HardwareMax - Web Promotion - Directory - Tuttosoft.it - Mondoroms - GBComputer -
Network: PHP Nuke Maximus - 1 Million Free Games - 1 Million Nuke Pixel - Corvoingordo - Ingegneria Gestionale - Torre del Greco - Testi ed Accordi gratis

Generazione pagina: 0.15 Secondi