JavaScript: corretta iterazione di liste

In programmazione capita spessissimo di dover iterare una lista di elementi. In JavaScript, questo è abbastanza semplice per degli Array (che in JavaScript hanno solo indici numerici) – basta usare un loop for ‘classico’: abc = [‘a’, ‘b’, ‘c’] for (var i = 0; i < abc.length; i++) { console.log(abc[i]); } A questo esempio si

Reindirizzamento con file .htaccess

Può essere utile sapere come reindirizzare gli utenti che giungono su un certo sito ad un altro.Il metodo più semplice ed efficace per ottenere questo è un redirect 301 (Permanent Redirect, reindirizzamento permanente) con un file .htaccess.Basta creare un normale file di testo chiamato .htaccess con i contenuti seguenti e caricarlo al dominio dal quale

Caricamento asincrono di file JS

Normalmente, quando uno script JS viene incluso attraverso HTML, il browser si ferma finché non ha interpretato lo script, poi continua con il resto del file HTML. Questo può causare rallentamenti al caricamento della pagina percepito dall’utente, specialmente se lo script in questione è molto grande o deve fare operazioni lunghe e laboriose. Un primo

Introducing JSON

JSON, or JavaScript Object Notation, is an open format for transferring data. It derives from the JavaScript language and is a popular alternative to XML because it’s lightweight and easily human-readable. Here’s what it might look like: { “name”: “John”, “surname”: “Smith”, “age”: 42, “address”: “Dent Street, Gallifrey”, “postal code”: “6900”, “tags”: [“time”, “traveller”] }

Precaricamento di immagini in JavaScript

Il precaricamento di immagini é una pratica usata spesso in JavaScript.Il concetto é molto semplice: una volta che il resto della pagina é stato caricato, si carica nella cache del browser l’immagine all’insaputa dell’utente.In questo modo, quando serve, l’immagine puó essere visualizzata più velocemente, senza più dover attendere che sia caricata.In molte applicazioni, questa tecnica

Creating a secure contact form

One common application in web development is creating a contact form. The basic concept is very simple: you display a form, the user submits it and you send the submitted input to your self. There is, however, and inherent danger in this form: spammer bots may use it to send spam not only to you,

PHP: creating an automatic and dynamic banner

In this article I will illustrate a relatively simple PHP application, but which contains a couple of useful techniques: creating an automatic and dynamic banner. To keep it simple, it will simply be a series of images, but these techniques could really be used for anything at all. Nonetheless, it will include a couple of