Click to See Complete Forum and Search --> : cookies help !!!


Ness_du_Frat
04-27-2005, 05:11 AM
Hello everybody !!! I have a problem with my cookies... Not the sweet ones, hm, the MEAN ones... lol !
No, really... Gaston helped me with cookies on my website ( thanks !!! ) but one of the cookies is not working well.. I think it comes from a simple mistake, but I can't find it...
So, let me explain it a bit : on my page, I have a scroll. And this scroll fades the text... to do that, I have two arrays : a startcolor value, and a endcolor value...
My website has a styleswitcher. And the startcolor value should change to apply to the different versions... and store the value in a cookie so that the user can have the version he prefers when he comes back on the website...
the page :

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Les Enfants de l'&Ocirc; - version 3.0 - Mayi</title>
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="css1.css" type="text/css" id="pStyle">
<base target="iframe1">
<script src="index.js"></script>
<script type="text/javascript">
<!--
function P7_writeStyles(op,a){ //v1.5 by PVII
if(op==0||document.getElementById){var tS="<sty"+"le type=\"text/css\">";
tS+=a+"<"+"/sty"+"le>";document.write(tS);document.close();}
}
P7_writeStyles(1,'.closed ul{display:none;}.open ul{display:block;}');
var endcolor=new Array(0,0,0); // end color (red, green, blue)
<!--

//cookie stuff here

var expiration=new Date();
expiration.setFullYear(expiration.getFullYear() + 1);
expiration=expiration.toGMTString();

var diedate=new Date();
diedate.setFullYear(diedate.getFullYear() - 1);
diedate=diedate.toGMTString();

function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { // if the cookie exists
offset += search.length
end = document.cookie.indexOf(";", offset); // set the index of beginning value

if (end == -1) // set the index of the end of cookie value
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function cookie() {
if(get_cookie('val')==""){
document.getElementById('pStyle').href='css1.css';
} else {
document.getElementById('pStyle').href='css'+get_cookie('val')+'.css';
}

if(get_cookie('title')==""){
document.title="Les Enfants de l'Ô - version 3.0 - Mayi";
} else {
document.title="Les Enfants de l'Ô - version 3.0 - "+get_cookie('title');
}

if(get_cookie('startcolor_red')=="" || get_cookie('startcolor_green')=="" || get_cookie('startcolor_blue')==""){
var startcolor=new Array(255,255,255);
} else {
var red=get_cookie('startcolor_red');
var green=get_cookie('startcolor_green');
var blue=get_cookie('startcolor_blue');
var startcolor=new Array(red, green, blue);
}
}

function showCookies(){
alert(unescape(document.cookie));
}

function deleteCookie(Name){
document.cookie=Name+"=;expires="+diedate;
}

//-->
</script>

<!--[if gte IE 5]>
<style>
#p7swapmenu ul a {height: 1em;}
</style>
<![endif]-->
<!--[if IE 5]>
<style>
#p7swapmenu li {margin-top: -3px;}
</style>
<![endif]-->
</head>
<body class="body" onload="document.urlForm.cUrl.value='http://psychomoa.free.fr/'+document.getElementById('iframe1').src;cookie()">
<div id="titre"></div>
<div id="logo"></div>
<div id="p7swapmenu">
// here comes the stuff for the menu. I shortened it, as it's not usefull for the problem I have...
</div>


<div id="titrenews"></div>

<div id="newsbas"></div>
<div id="news">
<script src="scroller.js"></script>
</div>
<div id="frame">
<iframe id="iframe1" name="iframe1" width="100%" height="100%" frameborder="0" src="edito2.htm"></iframe>
</div>

<div id="version">
<a href="#" target="IFrame2" onmousedown="sTop=top.frames['iframe1'].document.getElementsByTagName('body')[0].scrollTop" onclick="switchCSS(1);return false">White</a>
<!-- <a href="versioncheck2.php?newskin=1" target="IFrame2" onmousedown="sTop=top.frames['iframe1'].document.getElementsByTagName('body')[0].scrollTop" onclick="switchCSS(1);">White</a> -->
<a href="#" target="IFrame2" onmousedown="sTop=top.frames['iframe1'].document.getElementsByTagName('body')[0].scrollTop" onclick="switchCSS(2);return false">Violet</a>
<!-- <a href="versioncheck2.php?newskin=2" target="IFrame2" onmousedown="sTop=top.frames['iframe1'].document.getElementsByTagName('body')[0].scrollTop" onclick="switchCSS(2);">Violet</a> -->
<a href="#" target="IFrame2" onmousedown="sTop=top.frames['iframe1'].document.getElementsByTagName('body')[0].scrollTop" onclick="switchCSS(3);return false">Orange</a>
<!-- <a href="versioncheck2.php?newskin=3" target="IFrame2" onmousedown="sTop=top.frames['iframe1'].document.getElementsByTagName('body')[0].scrollTop" onclick="switchCSS(3);">Orange</a> -->
<a href="#" target="IFrame2" onmousedown="sTop=top.frames['iframe1'].document.getElementsByTagName('body')[0].scrollTop" onclick="switchCSS(4);return false">Bleu</a>
<!-- <a href="versioncheck2.php?newskin=4" target="IFrame2" onmousedown="sTop=top.frames['iframe1'].document.getElementsByTagName('body')[0].scrollTop" onclick="switchCSS(4);">Bleu</a> -->
<a href="#" target="IFrame2" onmousedown="sTop=top.frames['iframe1'].document.getElementsByTagName('body')[0].scrollTop" onclick="switchCSS(5);return false">Vert</a>
<!-- <a href="versioncheck2.php?newskin=5" target="IFrame2" onmousedown="sTop=top.frames['iframe1'].document.getElementsByTagName('body')[0].scrollTop" onclick="switchCSS(5);">Vert</a> -->
<select onChange="if(this.value!==0){ switchCSS(this.value); }">
<option value="0"></option>
<option value="1">White</option>
<option value="2">Violet</option>
<option value="3">Orange</option>
</select>
</div>
<div id="versiontitre"></div>
<form name="urlForm" action="#">
<input type="hidden" name="cUrl" value="">
</form>
<script language="JavaScript" type="text/javascript">
<!--
var sTop;
var ns=(!document.all&&(navigator.vendor=='Netscape'||navigator.vendor=='Netscape6')&&!window.opera)
//window.onerror=function(e){if(ns)return true;}
//window.onerror=function(e){if(ns)alert(e);return true;}

function switchCSS(val){
var title="Mayi";
var startcolor=new Array(255,255,255);
var endcolor=new Array(0,0,0); // end color (red, green, blue)
document.getElementById('pStyle').href='css'+val+'.css';
document.cookie='val='+val+';expires='+expiration+';path=/';
if (val==1)
{
strt='Mayi';
startcolor= new Array(255,255,255); // start color (red, green, blue)
startcolor_red= 255;
startcolor_green= 255;
startcolor_blue= 255;
title='Mayi';
}
if (val==2)
{
strt='Asla';
title='Asla';
startcolor= new Array(153,102,255); // start color (red, green, blue)
startcolor_red= 153;
startcolor_green= 102;
startcolor_blue= 255;

}
if (val==3)
{
strt='Okhanan';
startcolor= new Array(255,153,51); // start color (red, green, blue)
title='Okhanan';
startcolor_red= 255;
startcolor_green= 153;
startcolor_blue= 51;
}
if (val==4)
{
strt='Isaac';
startcolor= new Array(102,102,255); // start color (red, green, blue)
title='Isaac';
startcolor_red= 102;
startcolor_green= 102;
startcolor_blue= 255;
}
if (val==5)
{
strt='Lúka';
title='Lúka';
startcolor= new Array(153,255,153); // start color (red, green, blue)
startcolor_red= 153;
startcolor_green= 255;
startcolor_blue= 153;
}
document.cookie="title="+title+"; expires="+expiration+";path=/";
document.cookie="startcolor_red="+startcolor_red+"; expires="+expiration+";path=/";
document.cookie="startcolor_green="+startcolor_green+"; expires="+expiration+";path=/";
document.cookie="startcolor_blue="+startcolor_blue+"; expires="+expiration+";path=/";
document.title="Les Enfants de l'Ô - version 3.0 - "+strt;

if(ns){
if(typeof(top.frames['iframe1'])=='object'){
document.getElementById('iframe1_1').src =document.urlForm.cUrl.value;
//alert(top.frames[0].document.getElementById('p1').nodeName)
top.frames[0].document.getElementById('cStyle').href='css'+val+'.css';
//document.getElementById('iframe1_1').document.getElementById('cStyle').href='css'+val+'.css';
}
}
else{
sTop+=0;
top.frames['iframe1'].document.getElementById('cStyle').href='http://psychomoa.free.fr/css'+val+'.css';
if(navigator.vendor=='Firefox'){
setTimeout("top.frames['iframe1'].window.scrollTo(0,"+sTop+")",250);
}
else{
top.window.frames['iframe1'].window.scrollTo(0,sTop)
}
}
top.window.frames['IFrame2'].location.href='versioncheck2.php?newskin='+val;
}
//-->
</script>
<iframe name='IFrame2' id='IFrame2' style="width:0;height:0;border:none;" frameborder="0"></iframe>
</body>
</html>


the scroll should be in the left bottom corner, under News. And it doesn't show up... Why ????? The test page is here : test (http://psychomoa.free.fr/accueiltestcookie3.php)
Any help will be greatly appreciated !!!!
Ness

phpnovice
04-27-2005, 07:21 AM
For a start, you have this in your SELECT:

onChange="if(this.value!==0){ switchCSS(this.value); }"

which should, by all rights, be more like this:

onChange="
if(this.options[this.selectedIndex].value!='0') {
switchCSS(this.options[this.selectedIndex].value);
}
return true;"

Also, you have this:

<script src="scroller.js"></script>

which should be this:

<script src="scroller.js" type="text/javascript"></script>

Lastly, please explain exactly what you mean by this:
...on my page, I have a scroll.

7stud
04-27-2005, 07:31 AM
function P7_writeStyles(op,a){ //v1.5 by PVII
if(op==0||document.getElementById){var tS="<sty"+"le type=\"text/css\">";
tS+=a+"<"+"/sty"+"le>";document.write(tS);document.close();}
}
P7_writeStyles(1,'.closed ul{display:none;}.open ul{display:block;}');
var endcolor=new Array(0,0,0); // end color (red, green, blue)
<!--

//cookie stuff here

var expiration=new Date();
expiration.setFullYear(expiration.getFullYear() + 1);
expiration=expiration.toGMTString();

var diedate=new Date();
diedate.setFullYear(diedate.getFullYear() - 1);
diedate=diedate.toGMTString();

function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { // if the cookie exists
offset += search.length
end = document.cookie.indexOf(";", offset); // set the index of beginning value

if (end == -1) // set the index of the end of cookie value
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(off set, end))
}
}
return returnvalue;
}

function cookie() {
if(get_cookie('val')==""){
document.getElementById('pStyle').href='css1.css';
} else {
document.getElementById('pStyle').href='css'+get_c ookie('val')+'.css';
}

Also, don't ever put onload events in the <body> tag.

Ness_du_Frat
04-27-2005, 08:46 AM
function P7_writeStyles(op,a){ //v1.5 by PVII
if(op==0||document.getElementById){var tS="<sty"+"le type=\"text/css\">";
tS+=a+"<"+"/sty"+"le>";document.write(tS);document.close();}
}
P7_writeStyles(1,'.closed ul{display:none;}.open ul{display:block;}');
var endcolor=new Array(0,0,0); // end color (red, green, blue)
<!--

//cookie stuff here

var expiration=new Date();
expiration.setFullYear(expiration.getFullYear() + 1);
expiration=expiration.toGMTString();

var diedate=new Date();
diedate.setFullYear(diedate.getFullYear() - 1);
diedate=diedate.toGMTString();

function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { // if the cookie exists
offset += search.length
end = document.cookie.indexOf(";", offset); // set the index of beginning value

if (end == -1) // set the index of the end of cookie value
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(off set, end))
}
}
return returnvalue;
}

function cookie() {
if(get_cookie('val')==""){
document.getElementById('pStyle').href='css1.css';
} else {
document.getElementById('pStyle').href='css'+get_c ookie('val')+'.css';
}

Also, don't ever put onload events in the <body> tag.
I thought everybody already knew that this forum as a tendency to separate words... Of course, in my script, on the real page, offset is ONE word, as is get_cookie....
I shouldn't put onload events in the body tag ? Where should I put it ? I don't think that's why it's not working, but it might help... thanks !!!

Ness_du_Frat
04-27-2005, 08:48 AM
For a start, you have this in your SELECT:

onChange="if(this.value!==0){ switchCSS(this.value); }"

which should, by all rights, be more like this:

onChange="
if(this.options[this.selectedIndex].value!='0') {
switchCSS(this.options[this.selectedIndex].value);
}
return true;"

Also, you have this:

<script src="scroller.js"></script>

which should be this:

<script src="scroller.js" type="text/javascript"></script>

Lastly, please explain exactly what you mean by this:
ok, the select thing is useless. it was just here for test matters. I took it out of the page, and I put the "text/javascript" things back...
anyway, here is the script for the scroll :

[PHP]
// JavaScript Document
/***********************************************
* Fading Scroller- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var delay = 2000; //set delay between message change (in miliseconds)
var maxsteps=30; // number of steps to take to change from start color to endcolor
var stepdelay=40; // time in miliseconds of a single step
//**Note: maxsteps*stepdelay will be total time in miliseconds of fading effect

var fcontent=new Array();
begintag='<div style="font: normal 12px Arial; padding: 10px; text-align: justify;">'; //set opening tag, such as font declarations
fcontent[0]="<b>Quoi de neuf ?</b><br>Bientôt la publication en ligne du <a href='http://lesangdesmiroirs.free.fr' target='_blank'>Sang des Miroirs</a>";
fcontent[1]="Nouveau design pour les <a href='http://enfantsdelo.free.fr' target='_blank'>Enfants de l'Ô</a>";
fcontent[2]="Bon, j'en ai marre d'écrire des messages de pub, moi ;)";
closetag='</div>';

var fwidth='170px'; //set scroller width
var fheight='80px'; //set scroller height

var fadelinks=1; //should links inside scroller content also fade like text? 0 for no, 1 for yes.

///No need to edit below this line/////////////////


var ie4=document.all&&!document.getElementById;
var DOM2=document.getElementById;
var faderdelay=0;
var index=0;


/*Rafael Raposo edited function*/
//function to change content
function changecontent(){
if (index>=fcontent.length)
index=0
if (DOM2){
document.getElementById("fscroller").style.color="rgb("+startcolor[0]+", "+startcolor[1]+", "+startcolor[2]+")"
document.getElementById("fscroller").innerHTML=begintag+fcontent[index]+closetag
if (fadelinks)
linkcolorchange(1);
colorfade(1, 15);
}
else if (ie4)
document.all.fscroller.innerHTML=begintag+fcontent[index]+closetag;
index++
}

// colorfade() partially by Marcio Galli for Netscape Communications. ////////////
// Modified by Dynamicdrive.com

function linkcolorchange(step){
var obj=document.getElementById("fscroller").getElementsByTagName("A");
if (obj.length>0){
for (i=0;i<obj.length;i++)
obj[i].style.color=getstepcolor(step);
}
}

/*Rafael Raposo edited function*/
var fadecounter;
function colorfade(step) {
if(step<=maxsteps) {
document.getElementById("fscroller").style.color=getstepcolor(step);
if (fadelinks)
linkcolorchange(step);
step++;
fadecounter=setTimeout("colorfade("+step+")",stepdelay);
}else{
clearTimeout(fadecounter);
document.getElementById("fscroller").style.color="rgb("+endcolor[0]+", "+endcolor[1]+", "+endcolor[2]+")";
setTimeout("changecontent()", delay);

}
}

/*Rafael Raposo's new function*/
function getstepcolor(step) {
var diff
var newcolor=new Array(3);
for(var i=0;i<3;i++) {
diff = (startcolor[i]-endcolor[i]);
if(diff > 0) {
newcolor[i] = startcolor[i]-(Math.round((diff/maxsteps))*step);
} else {
newcolor[i] = startcolor[i]+(Math.round((Math.abs(diff)/maxsteps))*step);
}
}
return ("rgb(" + newcolor[0] + ", " + newcolor[1] + ", " + newcolor[2] + ")");
}

if (ie4||DOM2)
document.write('<div id="fscroller" width:'+fwidth+';height:'+fheight+'"></div>');

if (window.addEventListener)
window.addEventListener("load", changecontent, false)
else if (window.attachEvent)
window.attachEvent("onload", changecontent)
else if (document.getElementById)
window.onload=changecontent

Ness_du_Frat
04-27-2005, 08:56 AM
Sorry about the formatting. I closed the php tag, and wrote a few things below, but it cut it when I clicked the submit button. The editing doesn't do any good ( 8 tries ). So, I'll have to leave it like that...

So, that was the scroller... If anyone could tell me why my cookie thing doesn't work, it would be giant... thanks !!!

phpnovice
04-27-2005, 09:32 AM
Also, don't ever put onload events in the <body> tag.
For my information... Why is that, pray tell?

Ness_du_Frat
04-27-2005, 01:42 PM
I'd like to know, too... And if it's sooo bad, I'd like to know an alternative...
But if somebody could come up with a solution for my cookie problem, it wuold be even greater.. :D

phpnovice
04-27-2005, 01:57 PM
I just tried your page in IE and the cookie for the style switcher seems to be working just fine. So, what is the problem?

Ness_du_Frat
04-27-2005, 03:58 PM
oh, the style switcher works perfectly, I'm sure of it. Tested in Opera, IE, FF mac and PC, IE mac and PC and Netscape.
My problem is the scroll... There must be a problem with the synthax, cause it never appears...
I need the cookies, so that on each version, you have the corresponding scrolling colors...
The cookies work fine for the versions and for the title of the page, but NOT for the scroll, what I really don't understand.

Ultimater
04-27-2005, 04:14 PM
Well, Ness_du_Frat, it seems you got your help before I found your thread...

phpnovice
04-27-2005, 04:16 PM
Tell you what, try changing your BODY tag to this:

<body class="body" onload="
document.urlForm.cUrl.value = 'http://psychomoa.free.fr/' + document.getElementById('iframe1').src;
cookie();
changecontent();
return true;">

Ness_du_Frat
04-28-2005, 12:11 AM
that doesn't change anything... Anyway, the whole scroller function is called a bit further in the page, exactly where it should.
My scroller function works totally fine, like it is, if I don't put the cookies for the startcolor variable.
I mean, if I put :
var startcolor : new Array (255,255,255);
it will work perferctly fine, but that's not my point.
My point is to make the function work with the startcolor corresponding to the version currently in use.
And my question is : why doesn't my cookie script work for the startcolor variable, when it works for the title variable, and for the css ?????
Thanks for your help, anyway...
If somebody could check my cookie() function and tell me if I made a mistake in it, it wuold be giant....

phpnovice
04-28-2005, 07:24 AM
that doesn't change anything... Anyway, the whole scroller function is called a bit further in the page, exactly where it should.
Yes, but what I was trying to determine was if there was a conflict over the fact that the scroller is trying to use the onload event while you are already coding your own use of the onload event. Generally, two scripts trying to use the same event from two different places in the document ends up that only the last one to use it actually gets it. The fix in those cases is to merge such separate uses into a single use.

That is also why I wish somebody would answer a question when asked.
Also, don't ever put onload events in the <body> tag.For my information... Why is that, pray tell?

Ness_du_Frat
04-28-2005, 08:49 AM
Yeah. I would like to know that to...

Ultimater
04-28-2005, 02:19 PM
Ness_du_Frat, would ya mind clearing things up a bit for me to what you have so far and what you are trying to do so I don't have to take half-an-hour to try to figure-out this thread which I didn't follow :confused:

Ness_du_Frat
04-28-2005, 04:11 PM
Oh, I'm sorry !!!
On my main page, I have a scroll, showing links, and news, basically. I put the script of this scroll, at the beginning of this topic.
The scroll script as a startcolor value, which is an array, with RGB values, and an endcolor value, same thing.
On my website, i have a style switcher. 6 different colors. And of course, the startcolor values of the scroll should correpond to that.
First, I made a function with conditions. It works pretty well. The only problem was that, when the user comes back, he gets the version he chose ( cookie thingy ), but the scroll startcolor value is the default one, because it's not stored anywhere.
So I decided to use a cookie to store the startcolor value of each single version.
The point is, when the user comes back, he gets his version, as well as the scroll correponding to it.

The code for the main page is on the second post. You have also a link to the actual page.

Now, my problem is : the script which stores the value of startcolor doesn't work. Mainly, it might store the value, but doesn't give it back. I get a blank thing, instead of my scroll. ( it's in the box called News ).
Why is that so ??? I don't understand that part. There must be a mistake somewhere, because everything else works fine. I have a cookie which stores the style sheet, another one which stores the title pf the page ( different, according to the different versions ), and those two work great... So I don't know why this stupid scroll won't show...
:(
I hope that clears things up a bit...
Thanks for trying to help me !!! :p

Ultimater
04-28-2005, 04:26 PM
I looked at the test link in your first post and don't see how it's involved in the problem.
I also tried executing the code you provided in the first post and it's full of errors...
Where do I get a copy of index.js?

Ness_du_Frat
04-28-2005, 04:32 PM
full of errors ??? :eek: :(
Anyway, I'll give you the code for index.js... Just need to open dreamweaver. Too lazy to search through my computer.
You don't see how the test page is involved ? the scroll should be right in the left bottom corner, and it's not here. When it appears, and does it with the right colors ( fading from the background color to black : orange to black, violet to blak, green to black... you see the point ), it will mean the page works.

that's index.js. Nothing to do with the scroll, nothing to do with anything else than the menu, actually...


// JavaScript Document
function P7_swapClass(){ //v1.4 by PVII
var i,x,tB,j=0,tA=new Array(),arg=P7_swapClass.arguments;
if(document.getElementsByTagName){for(i=4;i<arg.length;i++){tB=document.getElementsByTagName(arg[i]);
for(x=0;x<tB.length;x++){tA[j]=tB[x];j++;}}for(i=0;i<tA.length;i++){
if(tA[i].className){if(tA[i].id==arg[1]){if(arg[0]==1){
tA[i].className=(tA[i].className==arg[3])?arg[2]:arg[3];}else{tA[i].className=arg[2];}
}else if(arg[0]==1 && arg[1]=='none'){if(tA[i].className==arg[2] || tA[i].className==arg[3]){
tA[i].className=(tA[i].className==arg[3])?arg[2]:arg[3];}
}else if(tA[i].className==arg[2]){tA[i].className=arg[3];}}}}
}

function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

window.status = "Les Enfants de l'Ô- Copyright Vanessa du Frat";

Ultimater
04-28-2005, 04:32 PM
Forget it, I found the JS file...

Ness_du_Frat
04-28-2005, 04:40 PM
And ???
You were disappointed... nothing is there. Right ? :D
I'm curious about the mistakes in the code... If you could point them out, so that I can correct them...
I know, sometimes I didn't put the type="text/javascript" on my scripts, but... does it matter so much ???

Ultimater
04-28-2005, 04:41 PM
The very end of the scoller.js file ends in:

if (window.addEventListener)
window.addEventListener("load", changecontent, false)
else if (window.attachEvent)
window.attachEvent("onload", changecontent)
else if (document.getElementById)
window.onload=changecontent


And your BODY also has an onload event...

Ness_du_Frat
04-28-2005, 04:43 PM
yeah, I know... But it worked very well when I didn't have the cookie things.

Ultimater
04-28-2005, 04:53 PM
OK, I looked at the getcookiemain.js and I found an error on the bottom:

if(get_cookie('val')!==""){
...
}else{
...
}

WTF is: !== ?
change that to: !=

Ness_du_Frat
04-28-2005, 05:04 PM
Don't kill me !!!!
*hides in a corner*
I changed it. Nothing bad happened. Nothing great either, though. The scroll is still not here...
when the page loads, it says : error on the page, line 41. The startcolor is not defined.
line 41 is :

function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { // if the cookie exists
offset += search.length
end = document.cookie.indexOf(";", offset); // set the index of beginning value

if (end == -1) // set the index of the end of cookie value
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end)) // line 41
}
}
return returnvalue;
}

Ultimater
04-28-2005, 05:13 PM
Your function cookie() defines startcolor as a local variable and not a global variable.
You might wanna change:

var startcolor=new Array(255,255,255);

into:

startcolor=new Array(255,255,255);

phpnovice
04-28-2005, 05:15 PM
W[hat] is: !== ?
change that to: !=
That is perfectly valid.

Nonidentity Operator (!==)

Compares two expressions to determine that they are not equal in value or of the same data type.

Ness_du_Frat
04-29-2005, 01:10 AM
thanks, phpnovice...
Anyway, the code is not from me :)
Ultimater, I'll try to define the variable in the way you suggested. Will tell you if it worked :)

Ness_du_Frat
04-29-2005, 01:16 AM
YEEEEEEAAAAAAAAHHHHHHHHHHH !!!!!!!!!
It was that : some variables were defined with var, whereas they should have been defined globaly...
Thank you sooooooo much !!!!!! I couldn't have figured it out... I tried changing the synthax earlier, but not for all of them...
Now, it works perfectly !!!!
*mega giant hug !!!!¨*

Ultimater
05-02-2005, 11:50 AM
I recieved your PM about your new problem concerning the page:
http://psychomoa.free.fr/chat.htm ( link (http://psychomoa.free.fr/chat.htm) )
So, I see your chat.htm page uses an IFRAME to load:
http://psychomoa.free.fr/chat/post.php ( link (http://psychomoa.free.fr/chat/post.php) )

I don't understand the part from your PM:

My main page has an iframe, which display the files... when the user clicks on the buttons to change the style, it changes also the style of the current page in the iframe, which is exactly what it should do. The problem comes now with iframe in the chat.htm file.


What do you mean by "when the user clicks on buttons to change the style?"
I saw no such controls in the chat.htm page. I've also tried to add to the chat a message but there's something wrong with it...
Does the chat work at all?

Ness_du_Frat
05-02-2005, 02:07 PM
hmmmm....
so, actually, it's normal that you :
1. don't see any buttons, because you're not on the right page...
2. can't make the chat to work, because on my test server, I don't have any database...

the link is :
http://enfantsdelo.free.fr/accueiltestcookie2.php

on the left, there is the a menu. When you click on Bonus, the first item is tagboard. That's my chat.

On the main page, you have 5 buttons. ( little round stuff just below the iframe ) When you click on them, the style of the main page AND the inner page change.
But : if you are currently on the tagboard ( file chat.htm ), and you click on the buttons, it will change the style from the form in the file chat.htm, but the inside of the iframe ( which is also in the file chat.htm ) won't change until you make a refresh of the page.
So, my question is : how to make a refresh on the page from the parent's parent's page ? ( I mean, accueiltestcookie2.php ( yeah, the name is weird. it's just a test name ), not chat.htm... )
I'm going to try with a reload script, maybe it works..
But you know, you scared me by saying my code is full of errors... :(

Ultimater
05-02-2005, 02:29 PM
Ahh, I see the problem. The reason why there is a flash of a white-color theme then it goes to your actual theme is because of this:


<link rel="stylesheet" href="css1.css" type="text/css" id="pStyle">

<body onload="document.urlForm.cUrl.value='http://enfantsdelo.free.fr/'+document.getElementById('iframe1').src;cookie()">


The CSS file links right-away to the href "css1.css" then waits for the onload event until correcting the href.
You should put that cookie() function call directly after the LINK tag.

Ness_du_Frat
05-02-2005, 02:48 PM
No, it's not at all what my problem is... I don't mind the falsh of white.. Ok, if it can be avoided, great, but my problem is the chat.htm file, and its iframe, which doesn't get the style...

Ultimater
05-02-2005, 02:53 PM
OH, I see what you mean now! If I have the current theme blue including the chat frame then I click one of them circle to change the theme, the chat window theme remains the old theme...
Oh, that should be easy to correct.

Ultimater
05-02-2005, 02:57 PM
you almost got it!

switchCSS(5);return false;self.frames['iframe1'].frames['tagboard'].location.reload()

move the return false to the end of the statement

Ness_du_Frat
05-02-2005, 03:04 PM
yyyyyyyyyyyyeeeeeeeeeeeaaaaaaaaaaahhhhhhhh !!!!!!



:D :D :D

that was it !!! Thankkkkkkkssssss !!!!! *giant hug*

BTW, what about the other problem ( which wasn't one until you pointed it out... I simply didn't notice it until now ) ? How should I change the script ? I should put the cookie thing inside of the link tag ??? O__o

Ultimater
05-02-2005, 03:07 PM
To fix the cookie thing, change:

<link rel="stylesheet" href="css1.css" type="text/css" id="pStyle">
<link rel="stylesheet" href="css.css" type="text/css">

into:
<link rel="stylesheet" href="css1.css" type="text/css" id="pStyle">
<script type="text/javascript">cookie()</script>
<link rel="stylesheet" href="css.css" type="text/css">




and change:
<body class="body" onload="document.urlForm.cUrl.value='http://enfantsdelo.free.fr/'+document.getElementById('iframe1').src;cookie()">


into:

<body class="body" onload="document.urlForm.cUrl.value='http://enfantsdelo.free.fr/'+document.getElementById('iframe1').src;">

Ness_du_Frat
05-02-2005, 03:13 PM
euh... the not so cool thing is : it doesn't work anymore... The inner page get the cookie, so it's got the style the user chose last time, but the main page is stuck in the white style... :eek:

Ultimater
05-02-2005, 03:50 PM
I'll take another look at it

Ultimater
05-02-2005, 03:51 PM
Can you update your webpage so I can play 'round with it?

Ness_du_Frat
05-03-2005, 12:33 AM
Ok, it's been updated... strange enough, it works on FF... Yesterday, it wasn't working on IE. I cannot test it today, because I'm on the mac.... and there is no PC around in a range of 10km... lol !!!
Seems a bit glitchy ( when you refresh the page, you get the mainpage to have css1.css, and the inner page has whatever style you just defined... )
Thanks !!!
If it works in IE for you, I assume it was my computer going crazy yesterday...

Ultimater
05-03-2005, 12:45 AM
Can you fully update it?
You only have one of the "color-dots" working.
i.e. self.frames['iframe1'].frames['tagboard'].location.reload(true)
the rest of the "color-dots" are all:
document.getElementById('tagboard').location.reload(true)

Can you change the rest for me?
Also, you don't need to reload the whole IFRAME to change it's color-theme.
You can use:
self.frames['iframe1'].frames['tagboard'].document.getElementsByTagName("LINK")[0].href="css1.css"
self.frames['iframe1'].frames['tagboard'].document.getElementsByTagName("LINK")[0].href="css2.css"
(etc)

Ultimater
05-03-2005, 01:01 AM
Get those changes done for me and I'll get back to work on it tomorrow.

Ultimater
05-03-2005, 01:05 AM
I'd recommand using the 2nd method I suggested (getElementsByTagName) .
The reason is because it will re-load the new theme faster.
And there should be no reason to re-fresh the whole IFRAME unless a different user entered-in a new post(which is highly unlikely).

Ness_du_Frat
05-03-2005, 01:20 AM
I uploaded the file... Actually, I prefer to refresh the iframe, as the people can also simply click the button they are on to refresh the test, and don't need to go to the iframe, make a right click, and refresh the page to see the new entries...
When I was saying the thing didn't work, I was refering to the other one, the one on the main page, with the cookie() script...
thank you sooooo much for what you've done ! It's really great !!

Ultimater
05-03-2005, 07:46 PM
Hmm... the function cookie gets called too early...

try changing:

<script type="text/javascript">cookie()</script>
<link rel="stylesheet" href="css.css" type="text/css">
<base target="iframe1">
<script src="index.js"></script>


into:

<link rel="stylesheet" href="css.css" type="text/css">
<base target="iframe1">
<script src="index.js"></script>
<script type="text/javascript">cookie()</script>


I think that that will do the trick. If not, try putting the cookie function call inside of
the BODY tag somewhere.
(by using the SCRIPT tag inside of the BODY tag)
If that doesn't work put it back in the onload event of the BODY tag :rolleyes:
(hope this isn't the case...)

Ness_du_Frat
05-04-2005, 04:56 AM
What do you mean by "inside of the body tag somewhere, by using the script tags ?" ?
Anyway, I put the function cookie() just after the body tag, before everything else, and... It WORKS !!!! :p :D
Thanks a lot !!!!
BTW, I will put you in the Thank Yous and Credits of the site, so if you want to give me a link so that can attach it to your name, or even a banner, :D

phpnovice
05-04-2005, 08:07 AM
I put the function cookie() just after the body tag, before everything else, and... It WORKS !
Yep, that is what he meant. ;)

Ness_du_Frat
05-04-2005, 09:26 AM
Yeah... One moment, I thought he wanted something like...
<body <script>cookie()</script>>...lol !!!!
i didn't even bother to try it. I think I'm getting wiser... :D

Ultimater
05-04-2005, 12:04 PM
You can add me to your credits as:
Ultimater with a link to: http://ultimiacian.tripod.com


In HTML, that would be:

<a href="http://ultimiacian.tripod.com" style="text-decoration: none;">
<font size="+1"><font color="blue"><font face="Script MT Bold, Bradley Hand ITC, Rage Italic, Papyrus, Felix, Titling, Imprint MT Shadow, Arial Black, Microsoft Sans Serif">U</font></font></font><font color="midiumslateblue">l</font><font color="royalblue">t</font><font color="midiumslateblue">i</font><font color="royalblue">m</font><font color="midiumslateblue">a</font><font color="royalblue">t</font><font color="midiumslateblue">e</font><font color="royalblue">r</font>
</a>


Ya wouldn't mind putting all the colors, would you? :D

Ness_du_Frat
05-04-2005, 02:32 PM
lol !!!
Ok, I'll gladly add you !!!! The site launch will normally be 1st of June, but that will depend on how much work I have...
The website presents the second part of my book : Enfants de l'Ô. So, I need to work on the book a bit, before releasing it :)
All the characters except the main 4 are called Truc or Machin ( Thing... )... I still need to work on the first 5 chapters, and correct some things. I wrote the first 5 chapters 5 years ago, and the 17 others were written in one year, so I have to check that there isn't any strange incoherent situation...
thanks for all the help !!!