I'm trying to set up skins for my website, and I can't seem to manage to get them to work properly, I just can't store the skins in the cookies properly or something, here's what I have:
This page
should allow you to set the cookie to the correct skin:
http://falkoner.cow.googlepages.com/SkinChanger.htmlCollapsable Box

<html>
<title>Change Settings</title>
<head>
<script type="text/javascript">
function setCookie(c_name,value)
{
document.cookie=c_name+ "=" +escape(value)+";";
}
</script>
</head>
<body>
<input type="button" value="Skin 1" onclick="setCookie(\"Skin\", \"
http://Falkoner.CoW.GooglePages.com/skin1.css\")"><input type="button" value="Skin 2" onclick="setCookie(\"Skin\", \"
http://Falkoner.CoW.GooglePages.com/skin2.css\")"></body>
</html>
This page
should pull the data of your current skin from the cookie and pick a CSS depending on what's in the cookie:
http://falkoner.cow.googlepages.com/SkinTester.htmlCollapsable Box

<html>
<title>Settings Tester</title>
<head>
<script type="text/javascript">
var CSSnum;
function getCookie(c_name)
{
if (document.cookie.length>0)
{
c_start=document.cookie.indexOf(c_name + "=");
if (c_start!=-1)
{
c_start=c_start + c_name.length+1;
c_end=document.cookie.indexOf(";",c_start);
if (c_end==-1) c_end=document.cookie.length;
return unescape(document.cookie.substring(c_start,c_end));
}
}
return "";
}
var theCSS=getCookie(Skin);
document.write(" <link rel=\"stylesheet\" type=\"text/css\"
href="+theCSS+" />");
</script>
</head>
<body>
<h1>testing h1</h1>
<h2>testing h2</h2>
</body>
</html>
And these are the two CSS pages that I am pulling it from:
http://falkoner.cow.googlepages.com/Skin1.cssCollapsable Box

h1 {color: green}
h2 {font-family: "sans-seriff"}
http://falkoner.cow.googlepages.com/Skin2.cssCollapsable Box

h1 {color: purple}
h2 {font-family: "impact"}
Can anyone check out the code and find what I did wrong?
Post has been edited 1 time(s), last time on Jul 14 2008, 7:29 pm by Falkoner.
None.
I know PHP better, but I can try and give this a go. I use to do some javascript.
Well for one to clean up your code, when you store the cookie you store the " " in the cookie. When you write out the stylesheet in javascript you also write out the " " again. While I would guess this would have no effect, I could be wrong and it could be trying to find a url that starts with "http:// and not
http://.However i'm doubting thats it.
Now my javascript and html are rusty as hell, however I think your setting the cookie "Skin", and checking the cookie Skin. It might just be from my experiences with C, but \" designates that you want " apart of the string. so \"Skin\" would output to "Skin" but u want Skin.
None.
Now my javascript and html are rusty as hell, however I think your setting the cookie "Skin", and checking the cookie Skin. It might just be from my experiences with C, but \" designates that you want " apart of the string. so \"Skin\" would output to "Skin" but u want Skin.
Yeah, I also program in C normally, and that's originally how I had it, but I talked with Doodle and he said I had to do it that way, here, I'll try it without the backslashes and see how it works out.
EDIT:
Okay:
http://falkoner.cow.googlepages.com/SkinChanger2.htmlhttp://falkoner.cow.googlepages.com/SkinTester2.htmlIt still didn't work

Perhaps something else?
None.

Relatively ancient and inactive
I'm pretty bad at Javascript, so I don't think I can really help with this, but you'll need more then different CSS files if you want a real skin system with different elements and all that. .tpl files are what most professional skinnable scripts use, though .html and all that can be used in conjunction with PHP 'require()' to create a very dynamic skin system.
None.
Well, I plan on basically just changing the top picture, the backround image, and the basic CSS using cookies, this is just a test. And the main reason I have to use cookies is because GooglePages doesn't allow PHP
None.
You still have "Skin\" rather than "Skin" on your settings page.
I'd also change Skin on the Settings Tester page to "Skin". Keep it consistent.
None.
Changed it, and it still doesn't work, and on the Setting Tester page I tried it with and without the quotes, neither worked.
EDIT: Here, I'll try not doing a string, and see if I can brute-force the skins.
EDIT:
Okay, that didn't work either.. I think I just have something wrong with my code, here's the new stuff, which still doesn't work:
http://falkoner.cow.googlepages.com/SkinChanger3.htmlhttp://falkoner.cow.googlepages.com/SkinTester3.htmlHere's the tutorial I've been trying to figure this out from:
http://w3schools.com/js/js_cookies.asp
Post has been edited 1 time(s), last time on Jul 14 2008, 8:22 pm by Falkoner.
None.
Hey, do you need to use the escape function to put data into a cookie? Like, if I don't care whether they manually edit it or not, can I skip using the escape function all together and just put unencrypted data in the cookie?
None.
Okay, I think the cookie sending is working correctly, because when I checked in my Cookies I found this:
Name: Skin
Content: http%3A//Falkoner.CoW.GooglePages.com/skin1.css
Host: falkoner.cow.googlepages.com
Path: /
Send for: Any type of connection
Expires: At end of session
So I think it's the reading of the cookie that isn't working properly now. Note that this is the code I used:
http://falkoner.cow.googlepages.com/SkinChanger4.htmlhttp://falkoner.cow.googlepages.com/SkinTester4.htmlI found that strings, when put into a function, must have ' around them.
Also, I'm wondering, since it says Expires: At end of session, does that mean when I close my browser it's gone? What does that mean? I want it to never expire, how can I do that?
None.
I know, sorry, for quadruple posting, but I've finally gotten the exact problem, here it is:
document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"+theCSS+\">");
What is wrong with that line of code? Or what is wrong with my two CSS pages? I managed to get it to print out the URL of the CSS exactly as it was supposed to be, using the theCSS variable, so I know it's in there properly, can anyone help me out here?
None.
FARTY IS THE BEST!He solved it for me over MSN, thanks guys
None.
The problem (just for those who are curious):
The quotes around +theCSS+ needed to be delimiters... not escaped or singlequoted. >.>
TinyMap2 - Latest in map compression! ( 7/09/14 - New build! )
EUD Action Enabler - Lightweight EUD/EPD support! (ChaosLauncher/MPQDraft support!)
EUDDB -
topic - Help out by adding your EUDs! Or Submit reference files in the References tab!
MapSketch - New image->map generator!
EUDTrig -
topic - Quickly and easily convert offsets to EUDs! (extended players supported)
SC2 Map Texture Mask Importer/Exporter - Edit texture placement in an image editor!
This page has been viewed [img]http://farty1billion.dyndns.org/Clicky.php?img.gif[/img] times!