First off, if you are going to do this onclick, use return false:
HTML Code:
<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:
Code:
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:
Code:
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
}
}
Bookmarks