Cookies - help needed !

M

martingerber

Hi,

I have the following script (javascript in html document):

<html>

<head>
<meta http-equiv="content-type"
content="text/html;charset=ISO-8859-1">
<title>Standort Speichern</title>
<link rel="stylesheet" type="text/css"
href="../../../stylesheets/styles.css">

<script language="javascript">

// 0=icon, 1=menue, 2=kopf, 3=task, 4=text, 5=bild, 6=navigation
// benötigt werden zum save nur die Frames 0, 2, 4, 5, 6

URL0 = top.window.opener.parent.frames[0].location.href;
// ist der Inhalt des Icon-Frames
URL1 = top.window.opener.parent.frames[2].location.href;
// ist der Inhalt des Kopf-Frames

URL2 = top.window.opener.parent.frames[4].location.href;
// ist der Inhalt des Text-Frames

URL3 = URL2.substring(0,URL2.length-5) + "b.htm"
// generiert aus dem eineindeutigen Text-Frame das dazugehörige
Bildframe, damit kann das Problem mit den
// verschiedenen Inhalten im Bildframe (b.htm, g.htm, gx.htm)
umschifft werden

URL4 = top.window.opener.parent.frames[6].location.href;
// ist der Inhalt des Navigation-Frames

function setCookie(CookieName, URL0, URL1, URL2, URL3, URL4, expires)
{
document.cookie = escape(CookieName) + "="
+ escape(CookieName) + "URL0$" + escape(URL0) + "&"
+ escape(CookieName) + "URL1$" + escape(URL1) + "&"
+ escape(CookieName) + "URL2$" + escape(URL2) + "&"
+ escape(CookieName) + "URL3$" + escape(URL3) + "&"
+ escape(CookieName) + "URL4$" + escape(URL4) + "&"
+ ((expires == null) ? "" : ("; expires=" +
expires.toGMTString()));
}

function save(UserName)
{
var today = new Date();
var expires = new Date();
expires.setTime(today.getTime() + 1000*60*60*24*365);
// setzt das Verfallsdatum des Cookies auf heute in einem Jahr
(ms*sec*min*h*d), da sonst das Cookie
// bei Schliessen des Browsers automatisch gelöscht wird
if (UserName != "")
{
CookieName = UserName;
setCookie(CookieName, URL0, URL1, URL2, URL3, URL4, expires);
}
}

</script>

</head>

<body class="basic">

<div align="center">
<h3>Standort speichern</h3>
</div>
<br>

<p>Bitte geben Sie im folgenden Textfeld den <strong>Namen des
Standorts</strong> ein unter dem Sie Ihren Lernstand speichern
wollen.</p>
<p>Nach dem Klicken auf die Schaltfl‰che
&quot;<strong>Speichern</strong>&quot;wird Ihr aktueller Standort
unter dem gew&auml;hlten Namen gespeichert.</p>
<br>
<form onSubmit="return false">
<center>
<div align="center">
<p>
<input TYPE="text" NAME="username" SIZE="20">
<input TYPE="button" style="font-family:Arial,
Helvetica;font-size:12px;font-weight:bold;background-color:#c2c2c2;color:
#000080"
value="Speichern"
onClick="javascript:save(this.form.username.value);window.close();">
</p>
</div>
</center>
</form>
<br><br><br>

<form NAME="Schaltfl&auml;che OK">
<div align="center">
<input type="button" style="font-family:Arial,Helvetica;
font-size:12px;font-weight:bold;background-color: #c2c2c2;color:
#000080"
name="Schaltfl&auml;che OK" onclick="window.close();"
value="Fenster schliessen">
</div>
</form>

</body>
</html>

What I want to do: save the actual position of a user in this
(learning) program. The screen is built of 7 frames (complex learning
context, needs 7 frames...) of which the url of 5 frames should be
saved in order to return to the actual posistion in the program later.
The script works on:
http://www.zahnpasten.hcbe.ch/home/inhalt/homepage/homepage.htm but
not on my side - HELP !!!!

ps: I am very unexperienced in programming

THANKS FOR ANY HELP
 
M

martingerber

Hi,

I have the following script (javascript in html document):

<html>

<head>
<meta http-equiv="content-type"
content="text/html;charset=ISO-8859-1">
<title>Standort Speichern</title>
<link rel="stylesheet" type="text/css"
href="../../../stylesheets/styles.css">

<script language="javascript">

// 0=icon, 1=menue, 2=kopf, 3=task, 4=text, 5=bild, 6=navigation
// benötigt werden zum save nur die Frames 0, 2, 4, 5, 6

URL0 = top.window.opener.parent.frames[0].location.href;
// ist der Inhalt des Icon-Frames
URL1 = top.window.opener.parent.frames[2].location.href;
// ist der Inhalt des Kopf-Frames

URL2 = top.window.opener.parent.frames[4].location.href;
// ist der Inhalt des Text-Frames

URL3 = URL2.substring(0,URL2.length-5) + "b.htm"
// generiert aus dem eineindeutigen Text-Frame das dazugehörige
Bildframe, damit kann das Problem mit den
// verschiedenen Inhalten im Bildframe (b.htm, g.htm, gx.htm)
umschifft werden

URL4 = top.window.opener.parent.frames[6].location.href;
// ist der Inhalt des Navigation-Frames

function setCookie(CookieName, URL0, URL1, URL2, URL3, URL4, expires)
{
document.cookie = escape(CookieName) + "="
+ escape(CookieName) + "URL0$" + escape(URL0) + "&"
+ escape(CookieName) + "URL1$" + escape(URL1) + "&"
+ escape(CookieName) + "URL2$" + escape(URL2) + "&"
+ escape(CookieName) + "URL3$" + escape(URL3) + "&"
+ escape(CookieName) + "URL4$" + escape(URL4) + "&"
+ ((expires == null) ? "" : ("; expires=" +
expires.toGMTString()));
}

function save(UserName)
{
var today = new Date();
var expires = new Date();
expires.setTime(today.getTime() + 1000*60*60*24*365);
// setzt das Verfallsdatum des Cookies auf heute in einem Jahr
(ms*sec*min*h*d), da sonst das Cookie
// bei Schliessen des Browsers automatisch gelöscht wird
if (UserName != "")
{
CookieName = UserName;
setCookie(CookieName, URL0, URL1, URL2, URL3, URL4, expires);
}
}

</script>

</head>

<body class="basic">

<div align="center">
<h3>Standort speichern</h3>
</div>
<br>

<p>Bitte geben Sie im folgenden Textfeld den <strong>Namen des
Standorts</strong> ein unter dem Sie Ihren Lernstand speichern
wollen.</p>
<p>Nach dem Klicken auf die Schaltfl?che
&quot;<strong>Speichern</strong>&quot;wird Ihr aktueller Standort
unter dem gew&auml;hlten Namen gespeichert.</p>
<br>
<form onSubmit="return false">
<center>
<div align="center">
<p>
<input TYPE="text" NAME="username" SIZE="20">
<input TYPE="button" style="font-family:Arial,
Helvetica;font-size:12px;font-weight:bold;background-color:#c2c2c2;color:
#000080"
value="Speichern"
onClick="javascript:save(this.form.username.value);window.close();">
</p>
</div>
</center>
</form>
<br><br><br>

<form NAME="Schaltfl&auml;che OK">
<div align="center">
<input type="button" style="font-family:Arial,Helvetica;
font-size:12px;font-weight:bold;background-color: #c2c2c2;color:
#000080"
name="Schaltfl&auml;che OK" onclick="window.close();"
value="Fenster schliessen">
</div>
</form>

</body>
</html>

What I want to do: save the actual position of a user in this
(learning) program. The screen is built of 7 frames (complex learning
context, needs 7 frames...) of which the url of 5 frames should be
saved in order to return to the actual posistion in the program later.
The script works on:
http://www.zahnpasten.hcbe.ch/home/inhalt/homepage/homepage.htm but
not on my side - HELP !!!!

ps: I am very unexperienced in programming

THANKS FOR ANY HELP

The script to load the content of the frames is:

<html>

<head>
<meta http-equiv="content-type"
content="text/html;charset=ISO-8859-1">

<title>Gespeicherten Standort laden</title>
<link rel="stylesheet" type="text/css"
href="../../../stylesheets/styles.css">
<script language="javascript">
function getCookie(CookieName, Variable)
{
search = escape(CookieName) + Variable;
if (document.cookie.length <= 0)
{
error = 2;
}
else
{
offset = document.cookie.indexOf(search);
if (offset == -1)
{
error = 1;
}
else
{
error = 0;
offset += search.length;
end = document.cookie.indexOf("&", offset);
if (end == -1) end = document.cookie.length-1;
return unescape(document.cookie.substring(offset, end));
}
}
}

function load(UserName)
{
if (UserName == "")
{
parent.window.close();
}
else
{
CookieName = UserName;

_URL0 = getCookie(CookieName, 'URL0$');
_URL1 = getCookie(CookieName, 'URL1$');
_URL2 = getCookie(CookieName, 'URL2$');
_URL3 = getCookie(CookieName, 'URL3$');
_URL4 = getCookie(CookieName, 'URL4$');
if (error == 0)
{
top.window.opener.parent.frames[0].location.href = _URL0;
top.window.opener.parent.frames[2].location.href = _URL1;
top.window.opener.parent.frames[4].location.href = _URL2;
top.window.opener.parent.frames[5].location.href = _URL3;
top.window.opener.parent.frames[6].location.href = _URL4;
// vergleiche die Framezuteilung: URLO in frame 0=icon, URL1
in frame 2=kopf
// URL2 in frame 4=text, URL3 (generiert aus URL2) in
frame5=bild, URL4
parent.window.close();
}
if (error != 0)
{
parent.document.writeln ( "<html><head><title>Error: Eintrag
nicht gefunden!</title></head>" )
parent.document.writeln ( "<body><body BGCOLOR=\"#D6E0DB\"
text=\"#000000\" link=\"#000080\" vlink=\"#000080\">" )
parent.document.writeln ( "<table border=\"0\" width=\"100%\"
bgcolor=\"#A4B0AB\"><tr><td width=\"100%\"><p align=\"center\"><font
color=\"#000000\" face=\"Arial\"><big><strong>Oops!</strong></big></font></td></tr></table>"
)
parent.document.writeln ( "<p>&nbsp;</p><p>&nbsp;</p><p
align=\"center\"><font size=\"3\" color=\"#000000\"
face=\"Arial\">Unter diesem Namen ist kein Standort
gespeichert!</font></p>" )
parent.document.writeln (
"<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><div
align=\"center\"><center><table BORDER=\"0\" CELLPADDING=\"4\"
CELLSPACING=\"0\" bgcolor=\"#A4B0AB\" width=\"100%\"><tr><td
align=\"center\">
<a href=\"javascript:window.history.back();\"><p><font
face=\"Arial\"> <p align=\"center\">zur&uuml;ck</font></p></a></td></tr></table></center></div>"
)
parent.document.writeln ( "</body></html>" )
parent.document.close()
}
}
}
</script>
</head>

<body class="basic">

<div align="center">
<h3>Gespeicherten Standort laden</h3>
</div>
<br>
<p>Bitte geben Sie im folgenden Textfeld den <strong>Namen des
Standorts</strong> ein unter dem Sie Ihren Lernstand abgespeichert
haben.</p>
<p>Nach dem Klicken auf die Schaltfl‰che
&quot;<strong>Laden</strong>&quot;wird Ihr gespeicherter Standort
geladen und automatisch im Browser-Fenster angezeigt.</p>
<p>t<a href="../../../jscript/history.js">estli</a>nk</p>
<br>
<form onSubmit="return false">
<div align="center">
<center>
<p>
<input TYPE="text" NAME="username" SIZE="25">
<input TYPE="button" style="font-family:Arial, Helvetica;
font-size:12px;
font-weight:bold;
background-color: #c2c2c2;
color: #000080"
value="Laden" onClick="load(this.form.username.value);"></p>
</center>
</div>
</form>
<br><br><br>
<form NAME="Schaltfl‰che OK">
<div align="center">
<input type="button" style="
font-family:Arial,Helvetica;
font-size:12px;
font-weight:bold;
background-color: #c2c2c2;
color: #000080"
name="Schaltfl‰che OK" onclick="window.close();" value="Fenster
schliessen"></font></div>
</form>
</body>
</html>

I tried everything and would be very grateful for help !!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,801
Messages
2,569,658
Members
45,421
Latest member
DoreenCorn

Latest Threads

Top