Javascript: Download sul tuo sito

Vi piacerebbe mettere a disposizione dei vostri utenti una sezione download da cui scaricare software utile? La soluzione più corretta è quella di rimandare l’utente ad un file interno. Ecco il codice per effettuare questa funzione:

 
// Recupero la querystring ed il nome del file da scaricare
var querystring = location.search;
var file = querystring.substring(6);
 
// Imposto la funzione di download
// con un link al file specificato
function Download()
{
    location.href = file;
}
 
// Imposto il messaggio
var msg;
 
// Verifico che sia stato specificato un file
// ed in caso lancio la funzione di download
if (file == "" || file == "undefined" || file.charAt(0) == " ")
{
    msg = "Nessun file specificato";
}
else
{
    msg = "Stà per partire il download del file " + file.bold();
    window.setTimeout("Download()", 5000);
}
 
// Stampo a video il messaggio
document.write(msg);

Articoli simili

  1. Posted luglio 7, 2009 at 8:39 pm

    I WANT JAVASCRIPT

Lascia un commento

Your email is never published nor shared. Required fields are marked *

*
*

This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)

You must read and type the 5 chars within 0..9 and A..F, and submit the form.

  

Oh no, I cannot read this. Please, generate a