marilynn.fowler
11-12-2010, 01:13 AM
I've avoided cookies for 12 years. I made my first cookie today:
<p><a href="projects.html" onclick="document.cookie='whichPic=8'">Set Cookie</a></p>
I have an external javascript sheet with an array of images w/text and the following code:
var current = 0;
function update() {
var pic = slides[current];
document.getElementById('proj_title').innerHTML = pic.title;
document.getElementById('proj_image').src = "images/slides/" + pic.image;
document.getElementById('proj_location').innerHTML = "<span>Location:</span> " + pic.location;
document.getElementById('proj_operation').innerHTML = "<span>Commercial Operation:</span> " + pic.commercial_operation;
document.getElementById('counter').innerHTML = (current + 1) + " of " + slides.length;
if(pic.link) {
document.getElementById('proj_link').style.display = "block";
document.getElementById('proj_href').href = pic.link;
} else {
document.getElementById('proj_link').style.display = "none";
}
}
When the user clicks the link, it should open the page to the slideshow and it should start on slide[8]. I think what I need to do is pass the value of the cookie to the variable "current", but I don't know how to do that. Also, I only need the cookie to last long enough for the new page to load (about 20 seconds), but all of the cookie scripts I've found set expiration in days.
Any guidance would be appreciated.
<p><a href="projects.html" onclick="document.cookie='whichPic=8'">Set Cookie</a></p>
I have an external javascript sheet with an array of images w/text and the following code:
var current = 0;
function update() {
var pic = slides[current];
document.getElementById('proj_title').innerHTML = pic.title;
document.getElementById('proj_image').src = "images/slides/" + pic.image;
document.getElementById('proj_location').innerHTML = "<span>Location:</span> " + pic.location;
document.getElementById('proj_operation').innerHTML = "<span>Commercial Operation:</span> " + pic.commercial_operation;
document.getElementById('counter').innerHTML = (current + 1) + " of " + slides.length;
if(pic.link) {
document.getElementById('proj_link').style.display = "block";
document.getElementById('proj_href').href = pic.link;
} else {
document.getElementById('proj_link').style.display = "none";
}
}
When the user clicks the link, it should open the page to the slideshow and it should start on slide[8]. I think what I need to do is pass the value of the cookie to the variable "current", but I don't know how to do that. Also, I only need the cookie to last long enough for the new page to load (about 20 seconds), but all of the cookie scripts I've found set expiration in days.
Any guidance would be appreciated.