View Full Version : Virtual Pagination Cookies Possible?

07-28-2007, 12:13 AM
1) Script Title: Virtual Pagination

2) Script URL (on DD): http://dynamicdrive.com/dynamicindex17/virtualpagination.htm

3) Describe problem:

Would anyone know of a way I can create cookies that would save the last dropdown link in the pagination script that the user visited. Therefore, if they leave the page with the Virtual Pagination content and comeback to it later, it will be on the same item they were looking at?

As an example, on the virtual pagination script page, the fifth example layout has a dropdown with 4 images (Castle, Park, Harvest, Country). Okay, say I visit the Virtual Paginate page and I dropdown and select the "Harvest" tab. Now, say I left the virtual paginate script and went somewhere else like google or whatever. Now, when I return back to this Virtual Paginate page, would it possible to have had a cookie keep track of the last visited dropdown selection I had (i.e. Harvest) and load the page on this one where I had left off?

Thanks so much in advance!:confused:

07-28-2007, 02:50 PM


I did this for one virtual pagination on a page. It could be worked out for as many as needed. No change was made to the virtualpaginate.js file. All additions were made in the body initialization script. Use your browser's "view source" to see the code.

Notes: If using this for more than one instance of virtual pagination on the page, you only need to add these functions once:

function createCookie(name,value,days) {
if (days) {
var date = new Date();
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;

Each instance would need its own:


following its initialization, with the word gallery changed to the variable name for that instance. It would also need to be added to the onunload event:


by giving it its own createCookie line in that function and once again changing the word gallery to its variable name.

07-29-2007, 07:51 PM

This worked like a charm! Thank you so much for taking the time to not only explain, but also provide an example!

Warmest Regards!