Closed Thread Icon

Preserved Topic: My Cookies Have Crumbled (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=17729" title="Pages that link to Preserved Topic: My Cookies Have Crumbled (Page 1 of 1)" rel="nofollow" >Preserved Topic: My Cookies Have Crumbled <span class="small">(Page 1 of 1)</span>\

 
Wes
Paranoid (IV) Mad Scientist

From: Inside THE BOX
Insane since: May 2000

posted posted 05-24-2000 20:16

Hey, all. Been lurking around here for a little while now and I feel pretty confident this group can help me out with my little Javascript problem.<P>I know pretty much nothing about Javascript. I'm a cut-n-paste sort of guy. So, talk to me like I'm a little kid if you deem it necessary.<P>I'm working to incorporate a unified look throughout my site now that I have a lot of content I'm confident with and I've started with this area: www.bigwaste.com/info/ <P>However, I should first explain how the site navigates. You enter through the front door (www.bigwaste.com) and choose one of six home pages. This is the eye candy portion of the site--the part where I have fun and the only pointless part I'm keeping on the site. (Doc, you may remember helping me with those blobs about 5 years ago.)<P>Once you've chosen a home page, it sets a cookie that records a path to the one you've chosen. (Look inside the HEAD of any of the six home pages to see how it sets the cookie.) Now, go to the URL above by clicking the appropriate link (currently called the Info Page everywhere else in the site).<P>At the top, you will see the first two links "Home" and "Front Door." If you click "Front Door," it takes you to the root index. If you click "Home," it should take you back to the home page you chose earlier. This part seems to work just fine.<P>HOWEVER, if you arrived in my site from anywhere but the front door or a home page (which is 95% of the time) you get a returned value of "null." For some reason, when I tested this all at home last night, it just returned blank and automatically went to the root. But, now at work it actually returns the word "null" and a friend of mine gets the same thing.<P>Please someone help we rewrite this script so that it will return something else by default (such as "http://www.bigwaste.com") if it doesn't find a cookie.<P>Thank you all very much. And as soon as I'm all done, I'd love for everyone to review the refurbished site.<P><P>Wes<P>The Big Waste of Space

Wes
Paranoid (IV) Mad Scientist

From: Inside THE BOX
Insane since: May 2000

posted posted 05-24-2000 20:34

I thought for the sake of convenience, I might post the scripts here so you didn't have to view my source.<P>Each home page contains this script to set the cookie:<P>document.cookie="homepage=/homepages/01; path=/";<P>(Of course, the number differs depending on which home page it is.)<P>The navigation template contains this script to retrieve the cookie:<P>function getCookie(name) {
var cookie = " " + document.cookie;
var search = " " + name + "=";
var setStr = null;
var offset = 0;
var end = 0;
if (cookie.length > 0) {
offset = cookie.indexOf(search);
if (offset != -1) {
offset += search.length;
end = cookie.indexOf(";", offset)
if (end == -1) {
end = cookie.length;
}
setStr = unescape(cookie.substring(offset, end));
}
}
return(setStr);
}<P>The "Home" link looks like this:<P><SCRIPT LANGUAGE="JavaScript">
document.write("<A HREF='");
document.write(getCookie("homepage"));
document.write("/'> ");</SCRIPT>
<IMG SRC="/nav_home.gif" NAME="zero" WIDTH=50 HEIGHT=19 BORDER=0 ALT="Home"></A><P>(I removed the MouseOver for clarity.)<P>Thanks again!
<P>Wes<P>The Big Waste of Space

DocOzone
Maniac (V) Lord Mad Scientist
Sovereign of all the lands Ozone and just beyond that little green line over there...

From: Stockholm, Sweden
Insane since: Mar 1994

posted posted 05-25-2000 01:12

OK, I was thinking maybe you could define your setStr variable different, instead of...<P>var setStr = null;<P>try this...<P>var setStr = "";<P>Sounds silly, doesn't it? Still, seems to me it might work for you, you'd get to the wrong place, but at least you wouldn't 404.<P><IMG SRC="http://www.ozones.com/forum/siggie.gif" border=0>

DocOzone
Maniac (V) Lord Mad Scientist
Sovereign of all the lands Ozone and just beyond that little green line over there...

From: Stockholm, Sweden
Insane since: Mar 1994

posted posted 05-25-2000 01:14

PS: Glad you decloaked, I remembered the Big Waste of Space quite well. Nice to have you here!<P>Your pal, -doc-

Wes
Paranoid (IV) Mad Scientist

From: Inside THE BOX
Insane since: May 2000

posted posted 05-25-2000 01:27

Argh! I tried changing that value before, but for some stupid reason I think I was using single quotes instead of double quotes. Seems so obvious now...<P>Works like a charm. Takes you back to the front door if no home page has yet been selected.<P>Thanks, Doc!
<P>Wes<P>The Big Waste of Space

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 05-26-2000 13:55

(Glad it works. But... single quotes and double quotes do exactly the same thing in JavaScript, so that couldn't have been the problem. Whatever. =)<P> <IMG SRC="http://www.angelfire.com/ma2/slimesareneat2/images/slimesig.gif">

« BackwardsOnwards »

Show Forum Drop Down Menu