470,594 Members | 1,411 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,594 developers. It's quick & easy.

cookie problem

Hi,

I get the follow problem.

A page is locate in C:\Directory\files\pag1.php
There I call the function setUrl. (all the functions are located in
C:\Directory\includes

function setUrl()
{

var ckyDatum = new Date;
ckyDatum.setDate(ckyDatum.getDate()+7);

var href = document.location.href;
the_cookie = escape(href);

document.cookie = 'test=' + the_cookie + '; path=/;' ;
alert(document.cookie);

}

This is OK : the alert results in ' test =
C\Directory\files\pag1.php
In a page located in C:\Directory\sub\pag5.php I call the function getUrl
<script language="JavaScript">
getUrl();
</script>

function getUrl()
{

var resultaat;

resultaat = leesUrl('test');
alert(resultaat); //OK
The alert results in
C\Directory\files\pag1.php

document.write ("<a href="+ resultaat + "><img
border='0'src='../afbeeldingen/Algemeen/terugbr.gif'></a>");

!!!!!!!!!!!!!!!!!!//this is not good. I get the follow a href:
C:\Directory\sub\c\Directory\files\pag1.php
}

function leesUrl(cookieName)

{
cookie_array = document.cookie.split ("; ")

for (x=0; x < cookie_array.length; x++)
{
cookieParts_array = cookie_array[x].split("=")
if (cookieParts_array[0] == cookieName)
{
alert (cookieParts_array[1]);
return cookieParts_array[1];
}
}
}

What's wrong?

Alain
Jul 23 '05 #1
1 1316

"alain dhaene" <a.******@instruct.be> wrote in message
news:40**********************@news.skynet.be...
The alert results in
C\Directory\files\pag1.php

document.write ("<a href="+ resultaat + "><img border='0'src='../afbeeldingen/Algemeen/terugbr.gif'></a>");
!!!!!!!!!!!!!!!!!!//this is not good. I get the follow a href:
C:\Directory\sub\c\Directory\files\pag1.php
What's wrong?

document.write will interpret backslashes in a string as escape characters
unless they are themselves escaped \\.
Easier to specify URLs using forward slashes '/' only.

--
S.C.
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Christoph Pieper | last post: by
2 posts views Thread by marshalli | last post: by
3 posts views Thread by Ben | last post: by
5 posts views Thread by Miljana | last post: by
6 posts views Thread by kelvlam | last post: by
5 posts views Thread by SJ | last post: by
29 posts views Thread by Jerim79 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.