Accueil > > > UNE LISTE GÉRÉE PAR COOKIES
UNE LISTE GÉRÉE PAR COOKIES
Information sur la source
Description
Ce script permet d'ajouter et d'enlever des "titres" (phrases ou suite de mots) entièrement grâces aux cookies. Marche entièrement sur ie et plus ou moins sur Mozilla
Source
- <html>
- <head>
-
- <SCRIPT LANGUAGE="JavaScript">
-
- <!-- début
- var expDays = 30;
- var exp = new Date();
- exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
- var ShowCount = 0;
- var SwapColour;
- function ListToDoItems() {
- var NumToDoItems = GetCookie('PT_NumToDoList');
- var i;
- var ToDoItem;
- if (NumToDoItems == null) {
- NumToDoItems = 0;
- }
- ShowCount = 0; SwapColour = 0;
- for (i=1; i <= NumToDoItems; i++) {
- ToDoItem = GetCookie('PT_ToDoItem'+i);
- if (ToDoItem != null) {
- PrintItem(ToDoItem, i);
- }
- }
- }
- function DeleteItem(Count) {
- DeleteCookie('PT_ToDoItem'+Count);
- window.location = window.location;
- }
- function PrintItem (ToDoItem, Count) {
- var color = "";
- SwapColour = 1 - SwapColour;
- if (SwapColour==1) {color = "bgcolor='#c0c0c0'"} ;
- ShowCount++;
- document.write("<tr " + color + ">");
- document.write("<td width=10% align=center valign=top><small><b>"+ShowCount);
- document.write("<td width=75% align=left ><small>"+ToDoItem);
- document.write("<td width=15% align=center><small>"+"<a href='javascript:DeleteItem(" + Count +
-
- ")'>Supprimer</a>");
- }
- function AddItem() {
- var NumToDoItems = GetCookie('PT_NumToDoList');
- var i;
- var ToDoItem;
- if (NumToDoItems == null) {
- NumToDoItems = 0;
- }
- ToDoItem = prompt("Entrer un nouveau titre");
- if ((ToDoItem != null) && (ToDoItem != "undefined" )) {
- NumToDoItems++;
- SetCookie('PT_ToDoItem'+NumToDoItems, ToDoItem, exp);
- SetCookie('PT_NumToDoList',NumToDoItems, exp);
- window.location = window.location;
- }
- }
- function set() {
- VisitorName = prompt("Qui êtes vous?");
- SetCookie ('VisitorName', VisitorName, exp);
- SetCookie ('WWHCount', 0, exp);
- SetCookie ('WWhenH', 0, exp);
- }
- function getCookieVal (offset) {
- var endstr = document.cookie.indexOf (";", offset);
- if (endstr == -1)
- endstr = document.cookie.length;
- return unescape(document.cookie.substring(offset, endstr));
- }
- function GetCookie (name) {
- var arg = name + "=";
- var alen = arg.length;
- var clen = document.cookie.length;
- var i = 0;
- while (i < clen) {
- var j = i + alen;
- if (document.cookie.substring(i, j) == arg)
- return getCookieVal (j);
- i = document.cookie.indexOf(" ", i) + 1;
- if (i == 0) break;
- }
- return null;
- }
- function SetCookie (name, value) {
- var argv = SetCookie.arguments;
- var argc = SetCookie.arguments.length;
- var expires = (argc > 2) ? argv[2] : null;
- var path = (argc > 3) ? argv[3] : null;
- var domain = (argc > 4) ? argv[4] : null;
- var secure = (argc > 5) ? argv[5] : false;
- document.cookie = name + "=" + escape (value) +
- ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
- ((path == null) ? "" : ("; path=" + path)) +
- ((domain == null) ? "" : ("; domain=" + domain)) +
- ((secure == true) ? "; secure" : "");
- }
- function DeleteCookie (name) {
- var exp = new Date();
- exp.setTime (exp.getTime() - 1);
- var cval = GetCookie (name);
- document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
- }
- // fin -->
- </script>
-
- </head>
-
- <body>
-
- <b><center><big>Dans la liste, il y a le(s) titre(s) :</big><center></b>
- <hr><br>
- <table width=100%>
- <SCRIPT LANGUAGE="JavaScript">
- <!-- début
- ListToDoItems();
- // fin -->
- </SCRIPT>
- </table>
- <br><hr>
- <center>
- <a href="javascript:AddItem()">Ajouter un titre</a>
- </center>
-
- </body>
- </html>
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
<!-- début
var expDays = 30;
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
var ShowCount = 0;
var SwapColour;
function ListToDoItems() {
var NumToDoItems = GetCookie('PT_NumToDoList');
var i;
var ToDoItem;
if (NumToDoItems == null) {
NumToDoItems = 0;
}
ShowCount = 0; SwapColour = 0;
for (i=1; i <= NumToDoItems; i++) {
ToDoItem = GetCookie('PT_ToDoItem'+i);
if (ToDoItem != null) {
PrintItem(ToDoItem, i);
}
}
}
function DeleteItem(Count) {
DeleteCookie('PT_ToDoItem'+Count);
window.location = window.location;
}
function PrintItem (ToDoItem, Count) {
var color = "";
SwapColour = 1 - SwapColour;
if (SwapColour==1) {color = "bgcolor='#c0c0c0'"} ;
ShowCount++;
document.write("<tr " + color + ">");
document.write("<td width=10% align=center valign=top><small><b>"+ShowCount);
document.write("<td width=75% align=left ><small>"+ToDoItem);
document.write("<td width=15% align=center><small>"+"<a href='javascript:DeleteItem(" + Count +
")'>Supprimer</a>");
}
function AddItem() {
var NumToDoItems = GetCookie('PT_NumToDoList');
var i;
var ToDoItem;
if (NumToDoItems == null) {
NumToDoItems = 0;
}
ToDoItem = prompt("Entrer un nouveau titre");
if ((ToDoItem != null) && (ToDoItem != "undefined" )) {
NumToDoItems++;
SetCookie('PT_ToDoItem'+NumToDoItems, ToDoItem, exp);
SetCookie('PT_NumToDoList',NumToDoItems, exp);
window.location = window.location;
}
}
function set() {
VisitorName = prompt("Qui êtes vous?");
SetCookie ('VisitorName', VisitorName, exp);
SetCookie ('WWHCount', 0, exp);
SetCookie ('WWhenH', 0, exp);
}
function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function DeleteCookie (name) {
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
// fin -->
</script>
</head>
<body>
<b><center><big>Dans la liste, il y a le(s) titre(s) :</big><center></b>
<hr><br>
<table width=100%>
<SCRIPT LANGUAGE="JavaScript">
<!-- début
ListToDoItems();
// fin -->
</SCRIPT>
</table>
<br><hr>
<center>
<a href="javascript:AddItem()">Ajouter un titre</a>
</center>
</body>
</html>
Conclusion
Ce script ne marche pas forcément sous Mozilla...
Sources du même auteur
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
TECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICESTECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICES par ROMELARD Fabrice
Animé par: Gaetan Bouveret et Julien Chomarat Business Connectivity Services (BCS) est dans SharePoint 2010 la version 2 de Business Data Catalog (BDC dans SharePoint 2007). Il s'agit de la solution permettant de visualiser des données provenan...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice [DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE[DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE par orion
Comme de nombreux geek, je suis un grand amateur de série TV et je rate régulièrement des épisodes de mes séries préférés. Une solution s'offre à vous avec ce merveilleux site : Tv Gorge - www.tvgorge.com Moteur de recherche à l'appui, vous pouvez ...
Cliquez pour lire la suite de l'article par orion TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Vincent Bellet et Baptiste Giraudier La BI dans SharePoint 2010, Les nouveaux services d'application dans SP2010 et SQL Server Reporting services 2008 R2. La BI dans SharePoint est généralisée pour tous afin de permettre à tous les coll...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2010 : PLAN DE MIGRATION VERS SHAREPOINT 2010TECHDAYS PARIS 2010 : PLAN DE MIGRATION VERS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Arnault Nouvel et Antoine Dongois Le processus à prendre : Apprendre (découvrir la plateforme) Préparer (documenter l'historique et choisir la méthode de MAJ) Test (Test de MAJ) Implémenter (Effectuer la MAJ) Valid...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Logiciels
DB-MAIN (9.1.0)DB-MAIN (9.1.0)DB-MAIN is a data-modeling and data-architecture tool. It is designed to help developers and anal... Cliquez pour télécharger DB-MAIN Xilisoft DPG Convertisseur (5.1.37.0120)XILISOFT DPG CONVERTISSEUR (5.1.37.0120)Xilisoft DPG Convertisseur offre aux fans de Nintendo DS une bonne solution leur permettant de dé... Cliquez pour télécharger Xilisoft DPG Convertisseur GraphicsGale (2.01.01)GRAPHICSGALE (2.01.01)GraphicsGale est un logiciel de PixelArt avec de nombreuse fonctionnalités permettant de réalisé ... Cliquez pour télécharger GraphicsGale Architecte 3D (Platinum 2010)ARCHITECTE 3D (PLATINUM 2010)Architecte 3D Platinium vous permet de concevoir facilement les plans votre future maison, de l'é... Cliquez pour télécharger Architecte 3D TeamViewer 5 (TeamViewer 5)TEAMVIEWER 5 (TEAMVIEWER 5)Dépanner un ami,expliquer une manipulation devient un jeu d'enfant.
Prise en main d'un autre ord... Cliquez pour télécharger TeamViewer 5
|