Orusbu Forum

Best forum
 
StartseitePortalKalenderFAQSuchenAnmeldenMitgliederNutzergruppenLogin

Teilen | 
 

 HTML Codes Cookies

Nach unten 
AutorNachricht
Admin
Admin
Admin


Anzahl der Beiträge : 48
Anmeldedatum : 01.03.08

BeitragThema: HTML Codes Cookies   Sa März 01, 2008 5:27 pm

Cookies:


Diese Codes müssen zwischen <head> und </head> eingefügt werden



zwischen <BODY> und </BODY>
Die Verwendung des Formulars ist optional. Hier kann ein Besucher anklicken, auf welche Seite er zukünftig direkt umgeleitet werden möchte.

<center>
<form>
<table><tr><td>
Please choose your Favorite Pet:<br>
<input type=checkbox name="cat" onClick="SetCookie('animal', this.name, exp);">Cat<br>
<input type=checkbox name="dog" onClick="SetCookie('animal', this.name, exp);">Dog<br>
<input type=checkbox name="gerbil" onClick="SetCookie('animal', this.name, exp);">Gerbil<br>
<input type=checkbox name="gopher" onClick="SetCookie('animal', this.name, exp);">Gopher<br>
</td></tr>
</table>
</form>
</center>


Ein Kalender, der Termine und Reminder in Cookies speichert:
<script language="javascript" src="cengine.js"></script>
<script language="javascript" src="other_scripts.js"></script>
<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
var mo = "";
var year = "";
var currentmonth = today.getMonth();
var currentyear = today.getFullYear();
//cookies are not found
if(document·cookie == "") {
mo = today.getMonth();
year = today.getFullYear();
}
else {
mo = getCookie('whichmonth');
//correct cookie is NOT set
if(mo == null) {
mo = today.getMonth();
year = today.getFullYear();
//alert number of reminders to user
alertReminders();
}
//correct cookie is set
else {
mo = getCookie('whichmonth');
year = getCookie('whichyear');
}
}
//set a session cookie
setCookie('whichmonth',mo);
setCookie('whichyear', year);
//backup one month and refresh
function backup() {
//check for a new year being set
if(mo > 0) {
mo--;
} else {
mo = 11;
//check for 19**
if(year == 2000) {
year = 1999;
} else if(year <= 1999) {
syear = year.substring(2,year.length);
syear--;
year = "19" + syear;
Number(year);
}
else {
year--;
}
}
setCookie('whichmonth',mo);
setCookie('whichyear', year);
//check for open child windows and close.
if(child && !child.closed) {
child.close();
}
document.location="calendar.html";
}
//go forward one month and refresh
function stepup() {
//check for a new year being set
if(mo < 11) {
mo++;
}
else {
mo = 0;
year++;
}
setCookie('whichmonth',mo);
setCookie('whichyear', year);
//check for open child windows and close.
if(child && !child.closed) {
child.close();
}
document.location="calendar.html";
}
//first starting day of month
var first = months[mo] + " 01, " + year;
firstday = new Date(first);
startday = firstday.getDay();
//variable for day count
var count = 1;
//variables for leap year
var factor = startday - 1;
var endday = parseInt(monthlen[mo]) + factor;
var calbg = "#666666";
var calwidth = "80%";
var twidth = "14%";
var theight = "70";
var monthbg = "#000000";
var monfam = "verdana,arial,helvetica";
var monsize = "3"
var moncol = "#ffffff"
var weekbg = "#eeeeee";
var weekfam = "verdana,arial,helvetica";
var weeksize = "2";
var weekcol = "#ff0000";
var daybg = "#eeeeee";
var dayfam = "verdana,arial,helvetica";
var daysize = "1";
var daycol = "#000000";
var sdaycol = "#ff0000";
var calendar = "";
calendar = "<table bgcolor='" + calbg + "' width='" + calwidth + "' border='0' cellpadding='1' cellspacing='0'>";
calendar += "<tr>";
calendar += "<td align='center'>";

<!-- Month Starts Here -->
calendar += "<table width='100%' border='0' cellpadding='3' cellspacing='0'>";
calendar += "<tr>";
calendar += "<td align='center'> <a href='javascript:backup();'><font color='#ffffff'><b><<</b></font></a> </td>";
calendar += "<td width='100%' bgcolor='" + monthbg + "' align='center'><font face='" + monfam + "' size=" + monsize + " color=" + moncol + "><b>";
calendar += "<a href='javascript://' onclick='open_all(\"all_reminders.html\");'><font color='#ffffff'>" + months[mo] + ", " + year + "</font></a>";
calendar += "</b></font></td>";
calendar += "<td align='center'> <a href='javascript:stepup();'><font color='#ffffff'><b>>></b></font></a> </td>";
calendar += "</tr>";
calendar += "</table>";
<!-- Month Ends Here -->

calendar += "</td>";
calendar += "</tr>";
calendar += "<tr>";
calendar += "<td align='center'>";

<!-- Week Starts Here -->
calendar += "<table width='100%' border='0' cellpadding='3' cellspacing='0'>";
calendar += "<tr>";
for(i = 0; i < 7; i++) {
calendar += "<td width='" + twidth + "' bgcolor='" + weekbg + "' align='center' valign='middle'><font face='" + weekfam + "' size=" + weeksize + " color=" + weekcol + "><b>";
calendar += days[i];
calendar += "</b></font></td>";
}
calendar += "</tr>";
calendar += "</table>";
<!-- Week Ends Here -->

calendar += "</td>";
calendar += "</tr>";
calendar += "<tr>";
calendar += "<td align='center'>";

<!-- Day Starts Here -->
calendar += "<table width='100%' border='0' cellpadding='2' cellspacing='1'>";
calendar += "<tr>";
if(startday > 0) {
for(empty = 0; empty < startday; empty++) {
calendar += "<td width='" + twidth + "' height='" + theight + "'> </td>";
}
}
for(i = startday; i <= endday; i++) {
if( (i % 7) == 0) {
calendar += "</tr><tr>";
}
//keep highlight info on the current month and day
if( (i - (startday - 1)) == dt && currentmonth == mo && currentyear == year) {
calendar += "<td width='" + twidth + "' height='" + theight + "' bgcolor='" + daybg + "' align='right' valign='top'><font face='" + dayfam + "' size=" + daysize + "><b>";
calendar += "<a href='javascript://' onclick=javascript:open_window('day_scheduler.html?" + months[mo] + "&" + count + "',300,350,0,1);><font color=" + sdaycol + ">" + count + "</font></a>";
if(currentmonth == mo && currentyear == year && document·cookie) {
var isremind = getCookie(months[mo] + count);
if(isremind) { //if a reminder exists for this day
isremind = isremind.split("|");
calendar += "<p><div align='center'><img src='reminder.gif' width='11' height='11' alt='you have " + isremind.length + " reminder(s)'></div>";
}
}
calendar += "</b></font></td>";
}
else {
calendar += "<td width='" + twidth + "' height='" + theight + "' bgcolor='" + daybg + "' align='right' valign='top'><font face='" + dayfam + "' size=" + daysize + ">";
calendar += "<a href='javascript://' onclick=javascript:open_window('day_scheduler.html?" + months[mo] + "&" + count + "',300,350,0,1);><font color=" + daycol + ">" + count + "</font></a>";
if(document·cookie) { //allows reminders to be displayed on other months
var isremind = getCookie(months[mo] + count);
if(isremind) { //if a reminder exists for this day
isremind = isremind.split("|");
calendar += "<p><div align='center'><img src='reminder.gif' width='11' height='11' alt='you have " + isremind.length + " reminder(s)'></div>";
}
}
calendar += "</font></td>";
}
count++;
}
calendar += "</tr>";
calendar += "</table>";
<!-- Day Ends Here -->

calendar += "</td>";
calendar += "</tr>";
calendar += "</table>";
function open_all(url) {
child = window.open(url,"allreminders", "width=430,height=400,resizable=0,scrollbars=1");
}
function alertReminders() {
var alertit = getCookie(months[today.getMonth()] + dt);
if(alertit != null) {
alertit = alertit.split("|");
//write out reminders into a string for display
textit = " 1. " + alertit[0];
for(var i = 1; i < alertit.length; i++) {
textit += "\n " + (i + 1) + ". " + alertit[i];
}
//alert user of number of reminders for which day and display those reminders
alert("You have " + alertit.length + " reminder(s) for " + months[today.getMonth()] + " " + dt + ".\n\n" + textit);
}
}
// End -->
</script>

zwischen <BODY> und </BODY>
<div align="center">
<table width="80%">
<tr>
<td align="right"><a href="javascript://" onclick="open_window('help_file.html',300,350,0,1);"><font face="verdana,arial,helvetica" size="2">help file</font></a></td>
</tr>
</table>
<script language="javascript">
<!--
document.write(calendar);
if(child && !child.closed) {
child.focus();
}
//-->
</script>
</div>


Ein Cookie merkt sich den letzten Besuch eines Surfers:
<SCRIPT LANGUAGE=JavaScript1.1 SRC="cookie1.js"></SCRIPT>
zwischen <body> und </body>
<SCRIPT LANGUAGE=JavaScript1.1>
// today
var now = new Date();

// one year in milliseconds
var one_year = 365*24*60*60*1000;

// one hour in milliseconds
var one_hour = 1*60*60*1000;

// expires in one year from now on
var expire_date = new Date();
expire_date.setTime(now.getTime()+one_hour);

var cookie_val = GetCookie("nf_java_intro");
if (cookie_val)
{
var last_visit = new Date();
last_visit.setTime(cookie_val);
document.writeln("Ihr letzter Besuch war am: ",last_visit.toLocaleString(),"<br>");
document.writeln("Aktuelles Datum: ",now.toLocaleString(),"<p>");
}
else
{
document.writeln("Dies ist Ihr erster Besuch.<p>");
}

SetCookie ("nf_java_intro", now.getTime(), expire_date, "/");

//-->
</SCRIPT>


mit Hilfe eines Cookies wird ein Popup- Fenster nur einmal geöffnet:
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var expDays = 1; // Lebensdauer des Cookies in Tagen

var page = "dummy.htm"; // Seite, die aufgerufen werden soll
var windowprops = "width=300,height=200,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=yes"; // Fenstereigenschaften

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();
}
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
function amt(){
var count = GetCookie('count')
if(count == null) {
SetCookie('count','1')
return 1
}
else {
var newcount = parseInt(count) + 1;
DeleteCookie('count')
SetCookie('count',newcount,exp)
return count
}
}
function getCookieVal(offset) {
var endstr = document·cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document·cookie.length;
return unescape(document·cookie.substring(offset, endstr));
}

function checkCount() {
var count = GetCookie('count');
if (count == null) {
count=1;
SetCookie('count', count, exp);

window.open(page, "", windowprops);

}
else {
count++;
SetCookie('count', count, exp);
}
}
// End -->
</script>

IN den <BODY> Tag
OnLoad="checkCount()"

cookiegesteuerte ToDo- Liste:
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var expDays = 30; //Lebensdauer des Cookies in Tagen
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 + ")'>Löschen</a>");
}
function AddItem() {
var NumToDoItems = GetCookie('PT_NumToDoList');
var i;
var ToDoItem;
if (NumToDoItems == null) {
NumToDoItems = 0;
}
ToDoItem = prompt("Neuer Eintrag");
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("Ihr Name?");
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();
}
// End -->
</script>

zwischen <BODY> und </BODY>
<b><center><big>To Do Liste</big><center></b>
<hr><br>
<table width=100%>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
ListToDoItems();
// End -->
</SCRIPT>
</table>
<br><hr>
<center>
<a href="javascript:AddItem()">hinzufügen</a>
</center>


Das Wars!
Very Happy
Nach oben Nach unten
Benutzerprofil anzeigen http://www.orusbu70.de.tl
 
HTML Codes Cookies
Nach oben 
Seite 1 von 1
 Ähnliche Themen
-
» Gibt es eine Möglichkeit, dass bei Firefox html codes angezeigt werden?
» WO Html-Codes?
» Thanks Button & html Codes
» HTML Codes von anderen Seiten in Module einsetzen.
» HTML codes Schnee schneien? wie?

Befugnisse in diesem ForumSie können in diesem Forum nicht antworten
Orusbu Forum :: HTML Codes-
Gehe zu: