Cookies - help needed !

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • martingerber

    #1

    Cookies - help needed !

    Hi,

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

    <html>

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

    <script language="javas cript">

    // 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.open er.parent.frame s[0].location.href;
    // ist der Inhalt des Icon-Frames
    URL1 = top.window.open er.parent.frame s[2].location.href;
    // ist der Inhalt des Kopf-Frames

    URL2 = top.window.open er.parent.frame s[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.open er.parent.frame s[6].location.href;
    // ist der Inhalt des Navigation-Frames

    function setCookie(Cooki eName, URL0, URL1, URL2, URL3, URL4, expires)
    {
    document.cookie = escape(CookieNa me) + "="
    + escape(CookieNa me) + "URL0$" + escape(URL0) + "&"
    + escape(CookieNa me) + "URL1$" + escape(URL1) + "&"
    + escape(CookieNa me) + "URL2$" + escape(URL2) + "&"
    + escape(CookieNa me) + "URL3$" + escape(URL3) + "&"
    + escape(CookieNa me) + "URL4$" + escape(URL4) + "&"
    + ((expires == null) ? "" : ("; expires=" +
    expires.toGMTSt ring()));
    }

    function save(UserName)
    {
    var today = new Date();
    var expires = new Date();
    expires.setTime (today.getTime( ) + 1000*60*60*24*3 65);
    // 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(Cooki eName, 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>S peichern</strong>&quot;wi rd Ihr aktueller Standort
    unter dem gew&auml;hlten Namen gespeichert.</p>
    <br>
    <form onSubmit="retur n 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;bac kground-color:#c2c2c2;c olor:
    #000080"
    value="Speicher n"
    onClick="javasc ript:save(this. form.username.v alue);window.cl ose();">
    </p>
    </div>
    </center>
    </form>
    <br><br><br>

    <form NAME="Schaltfl& auml;che OK">
    <div align="center">
    <input type="button" style="font-family:Arial,He lvetica;
    font-size:12px;font-weight:bold;bac kground-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/i...e/homepage.htm but
    not on my side - HELP !!!!

    ps: I am very unexperienced in programming

    THANKS FOR ANY HELP
  • martingerber

    #2
    Re: Cookies - help needed !

    martingerber@ma c.com (martingerber) wrote in message news:<bbed1d18. 0311140151.6e8e fe7d@posting.go ogle.com>...[color=blue]
    > Hi,
    >
    > I have the following script (javascript in html document):
    >
    > <html>
    >
    > <head>
    > <meta http-equiv="content-type"
    > content="text/html;charset=IS O-8859-1">
    > <title>Stando rt Speichern</title>
    > <link rel="stylesheet " type="text/css"
    > href="../../../stylesheets/styles.css">
    >
    > <script language="javas cript">
    >
    > // 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.open er.parent.frame s[0].location.href;
    > // ist der Inhalt des Icon-Frames
    > URL1 = top.window.open er.parent.frame s[2].location.href;
    > // ist der Inhalt des Kopf-Frames
    >
    > URL2 = top.window.open er.parent.frame s[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.open er.parent.frame s[6].location.href;
    > // ist der Inhalt des Navigation-Frames
    >
    > function setCookie(Cooki eName, URL0, URL1, URL2, URL3, URL4, expires)
    > {
    > document.cookie = escape(CookieNa me) + "="
    > + escape(CookieNa me) + "URL0$" + escape(URL0) + "&"
    > + escape(CookieNa me) + "URL1$" + escape(URL1) + "&"
    > + escape(CookieNa me) + "URL2$" + escape(URL2) + "&"
    > + escape(CookieNa me) + "URL3$" + escape(URL3) + "&"
    > + escape(CookieNa me) + "URL4$" + escape(URL4) + "&"
    > + ((expires == null) ? "" : ("; expires=" +
    > expires.toGMTSt ring()));
    > }
    >
    > function save(UserName)
    > {
    > var today = new Date();
    > var expires = new Date();
    > expires.setTime (today.getTime( ) + 1000*60*60*24*3 65);
    > // 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(Cooki eName, 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>S peichern</strong>&quot;wi rd Ihr aktueller Standort
    > unter dem gew&auml;hlten Namen gespeichert.</p>
    > <br>
    > <form onSubmit="retur n 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;bac kground-color:#c2c2c2;c olor:
    > #000080"
    > value="Speicher n"
    > onClick="javasc ript:save(this. form.username.v alue);window.cl ose();">
    > </p>
    > </div>
    > </center>
    > </form>
    > <br><br><br>
    >
    > <form NAME="Schaltfl& auml;che OK">
    > <div align="center">
    > <input type="button" style="font-family:Arial,He lvetica;
    > font-size:12px;font-weight:bold;bac kground-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/i...e/homepage.htm but
    > not on my side - HELP !!!!
    >
    > ps: I am very unexperienced in programming
    >
    > THANKS FOR ANY HELP[/color]

    The script to load the content of the frames is:

    <html>

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

    <title>Gespeich erten Standort laden</title>
    <link rel="stylesheet " type="text/css"
    href="../../../stylesheets/styles.css">
    <script language="javas cript">
    function getCookie(Cooki eName, Variable)
    {
    search = escape(CookieNa me) + Variable;
    if (document.cooki e.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(docume nt.cookie.subst ring(offset, end));
    }
    }
    }

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

    _URL0 = getCookie(Cooki eName, 'URL0$');
    _URL1 = getCookie(Cooki eName, 'URL1$');
    _URL2 = getCookie(Cooki eName, 'URL2$');
    _URL3 = getCookie(Cooki eName, 'URL3$');
    _URL4 = getCookie(Cooki eName, 'URL4$');
    if (error == 0)
    {
    top.window.open er.parent.frame s[0].location.href = _URL0;
    top.window.open er.parent.frame s[2].location.href = _URL1;
    top.window.open er.parent.frame s[4].location.href = _URL2;
    top.window.open er.parent.frame s[5].location.href = _URL3;
    top.window.open er.parent.frame s[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.c lose();
    }
    if (error != 0)
    {
    parent.document .writeln ( "<html><head><t itle>Error: Eintrag
    nicht gefunden!</title></head>" )
    parent.document .writeln ( "<body><bod y BGCOLOR=\"#D6E0 DB\"
    text=\"#000000\ " link=\"#000080\ " vlink=\"#000080 \">" )
    parent.document .writeln ( "<table border=\"0\" width=\"100%\"
    bgcolor=\"#A4B0 AB\"><tr><td width=\"100%\"> <p align=\"center\ "><font
    color=\"#000000 \" face=\"Arial\"> <big><strong>Oo ps!</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><tabl e BORDER=\"0\" CELLPADDING=\"4 \"
    CELLSPACING=\"0 \" bgcolor=\"#A4B0 AB\" width=\"100%\"> <tr><td
    align=\"center\ ">
    <a href=\"javascri pt:window.histo ry.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>Gespeichert en 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>L aden</strong>&quot;wi rd Ihr gespeicherter Standort
    geladen und automatisch im Browser-Fenster angezeigt.</p>
    <p>t<a href="../../../jscript/history.js">est li</a>nk</p>
    <br>
    <form onSubmit="retur n 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(t his.form.userna me.value);"></p>
    </center>
    </div>
    </form>
    <br><br><br>
    <form NAME="Schaltfl‰ che OK">
    <div align="center">
    <input type="button" style="
    font-family:Arial,He lvetica;
    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 !!

    Comment

    Working...