Pagina 9 di 9 primaprima ... 7 8 9
Visualizzazione dei risultati da 81 a 87 su 87
  1. #81
    Utente di HTML.it L'avatar di carlomarx
    Registrato dal
    Oct 2009
    Messaggi
    1,669

    Evergreen

    Usare i cookies (da: https://developer.mozilla.org/en/DOM/document.cookie)…:

    codice:
    docCookies = {
      getItem: function (sKey) {
        if (!sKey || !this.hasItem(sKey)) { return null; }
        return unescape(document.cookie.replace(new RegExp("(?:^|.*;\\s*)" + escape(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*"), "$1"));
      },
      /**
      * docCookies.setItem(sKey, sValue, vEnd, sPath, sDomain, bSecure)
      *
      * @argument sKey (String): the name of the cookie;
      * @argument sValue (String): the value of the cookie;
      * @optional argument vEnd (Number, String, Date Object or null): the max-age in seconds (e.g., 31536e3 for a year) or the
      *  expires date in GMTString format or in Date Object format; if not specified it will expire at the end of session; 
      * @optional argument sPath (String or null): e.g., "/", "/mydir"; if not specified, defaults to the current path of the current document location;
      * @optional argument sDomain (String or null): e.g., "example.com", ".example.com" (includes all subdomains) or "subdomain.example.com"; if not
      * specified, defaults to the host portion of the current document location;
      * @optional argument bSecure (Boolean or null): cookie will be transmitted only over secure protocol as https;
      * @return undefined;
      **/
      setItem: function (sKey, sValue, vEnd, sPath, sDomain, bSecure) {
        if (!sKey || /^(?:expires|max\-age|path|domain|secure)$/.test(sKey)) { return; }
        var sExpires = "";
        if (vEnd) {
          switch (typeof vEnd) {
            case "number": sExpires = "; max-age=" + vEnd; break;
            case "string": sExpires = "; expires=" + vEnd; break;
            case "object": if (vEnd.hasOwnProperty("toGMTString")) { sExpires = "; expires=" + vEnd.toGMTString(); } break;
          }
        }
        document.cookie = escape(sKey) + "=" + escape(sValue) + sExpires + (sDomain ? "; domain=" + sDomain : "") + (sPath ? "; path=" + sPath : "") + (bSecure ? "; secure" : "");
      },
      removeItem: function (sKey) {
        if (!sKey || !this.hasItem(sKey)) { return; }
        var oExpDate = new Date();
        oExpDate.setDate(oExpDate.getDate() - 1);
        document.cookie = escape(sKey) + "=; expires=" + oExpDate.toGMTString() + "; path=/";
      },
      hasItem: function (sKey) { return (new RegExp("(?:^|;\\s*)" + escape(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=")).test(document.cookie); }
    };
    
    // docCookies.setItem("test1", "Hello world!");
    // docCookies.setItem("test2", "Hello world!", new Date(2020, 5, 12));
    // docCookies.setItem("test3", "Hello world!", new Date(2027, 2, 3), "/blog");
    // docCookies.setItem("test4", "Hello world!", "Sun, 06 Nov 2022 21:43:15 GMT");
    // docCookies.setItem("test5", "Hello world!", "Tue, 06 Dec 2022 13:11:07 GMT", "/home");
    // docCookies.setItem("test6", "Hello world!", 150);
    // docCookies.setItem("test7", "Hello world!", 245, "/content");
    // docCookies.setItem("test8", "Hello world!", null, null, "example.com");
    // docCookies.setItem("test9", "Hello world!", null, null, null, true);
    
    // alert(docCookies.getItem("test1"));

  2. #82
    Utente di HTML.it L'avatar di carlomarx
    Registrato dal
    Oct 2009
    Messaggi
    1,669
    Motore di ricerca con suggerimenti durante la digitazione (javascript + php):

  3. #83
    Utente di HTML.it L'avatar di carlomarx
    Registrato dal
    Oct 2009
    Messaggi
    1,669

    Evergreen

    Uso standard di ajax (asincrono e senza invio di dati al server):

    https://developer.mozilla.org/En/Usi...external_files

  4. #84
    Utente di HTML.it L'avatar di carlomarx
    Registrato dal
    Oct 2009
    Messaggi
    1,669

    Leggere il contenuto di un file immagine e convertirlo in stringa base64

    Se l'immagine si trova sul server:

    http://developer.mozilla.org/en/Code...base64_strings

    Se l'immagine si trova in locale:

    http://developer.mozilla.org/en/DOM/...sDataURL%28%29

  5. #85
    Utente di HTML.it L'avatar di carlomarx
    Registrato dal
    Oct 2009
    Messaggi
    1,669
    Un po' di convenzioni di buon codice:

    http://javascript.crockford.com/code.html

  6. #86
    Utente di HTML.it L'avatar di Xinod
    Registrato dal
    Sep 2000
    Messaggi
    13,649
    Originariamente inviato da Xinod
    per favore Carlo, non postare gli script direttamente qui,
    apri una discussione apposita per lo script, anche nell' eventualita' se ne voglia discutere piu' approfonditamente
    ora basta, chiudo momentaneamente

  7. #87
    Moderatore di JavaScript L'avatar di br1
    Registrato dal
    Jul 1999
    Messaggi
    19,998
    Plugin jquery per facilitare l'uso delle mapppe google: http://forum.html.it/forum/showthrea...2#post13838042
    Il guaio per i poveri computers e' che sono gli uomini a comandarli.

    Attenzione ai titoli delle discussioni: (ri)leggete il regolamento
    Consultate la discussione in rilievo: script / discussioni utili
    Usate la funzione di Ricerca del Forum

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.