cookie problem

A

alain dhaene

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
 
S

Stephen Chalmers

The alert results in
C\Directory\files\pag1.php

document.write ("<a href="+ resultaat + "><img
border='0'src='../afbeeldingen/Algemeen/terugbr.gif'> said:
!!!!!!!!!!!!!!!!!!//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.
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top