PDA

View Full Version : Image Thumbnail Viewer II help



Yowhatever
07-26-2006, 11:29 PM
Well, i've looked through tons of different threads about this, but yet to see my question.

1) Script Title: Image Thumbnail Viewer II

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex4/thumbnail2.htm

3) Describe problem: It's not exactly a problem, but more of asking for help...

LINK TO THE PAGE: http://users.adelphia.net/~jborgerding/Home.htm
(click the "9:00" thing located at the bottom footer)

The code is working great, loving everything it does, BUT! I would like to know a way, (if possible) to have it load the last image you viewed. Currently I have it where you have click it to show up, instead of just scrolling over. anyways. I just want it to have the initial image the last one you clicked. Is there a different code I should use that would be more effective? or is this the right one.

Thanks for the help... sorry if it's a tad bit confusing.

EDIT: Something like a cookie.

jscheuer1
07-27-2006, 05:31 AM
First off, if you are going to do this onclick, use return false:


<a href="#" onClick="modifyimage('dynloadarea', 1);return false;">

That way the page won't reload every time to 'pagename'#. OK, to use a cookie, you can add this (cookie unit courtesy of quirksmode.org) and onload function to the end of the script:


function createCookie(name,value,days)
{
if (days)
{
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++)
{
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}

function eraseCookie(name)
{
createCookie(name,"",-1);
}
onload=function(){
var sdex=readCookie('idex')
if (sdex)
modifyimage('dynloadarea', sdex)
}

And, add this line (red) to the modifyimage() function:


function modifyimage(loadarea, imgindex){
if (document.getElementById){
createCookie('idex', imgindex)
var imgobj=document.getElementById(loadarea)
if (imgobj.filters && window.createPopup){
imgobj.style.filter=filterstring
imgobj.filters[0].Apply()
}
imgobj.innerHTML=returnimgcode(dynimages[imgindex])
if (imgobj.filters && window.createPopup)
imgobj.filters[0].Play()
return false
}
}

Yowhatever
07-27-2006, 07:21 AM
I'm positive it's just me, but It appers to not be working..?

jscheuer1
07-27-2006, 07:36 AM
Well, I just checked your demo page and it hasn't changed. I can't tell what the problem is if I cannot see what you did. I made a local copy here and it did work by the way.

Yowhatever
07-27-2006, 08:27 AM
okay my bad, I took all the stuff off because I wanted to start over, and had to leave...

anyways... check now, I updated it. Thanks!

EDIT: YOU ARE A GOD RIGHT NOW (in my mind... =P)

Thanks you soooooo much!!!!!! It works great!