Path Breadcrumbs in Javascript - Possible?



I have been looking for a way to use Javascript to implement Path
Breadcrumbs. Searching the internet, I only find reference to Location
Breadcrumbs in Javscript. I am a fairly new Javascript (and web, in
general) programmer but have many years experience in programming. As I
thought about the problem, a possible method occurred to me but, as I am not
yet experienced enough in Javascript to know all the necessary bits and
pieces, I simply am posting here the framework for a method I think should
work, and leaving it up to some experienced and creative Javascript
programmer to determine whether what i suggest actually would work. Here is
an outline of the framework (NOTE: in the outline, whenever I use a verb,
interpret it as meaning "write a javascript function to do [verb]")

1) When visitor first enters your site, construct a session cookie with a
[value] field containing the URL and (say) page title. Lets refer to the
[value] field subsequently as 'visitor_path'. We'll be using it as a sort
of stack.
2) When visitor links to any other page, use an 'onload' function to read
the cookie and modify it as follows:
a) if current_page equals the next-to-last page in visitor_path (the user
has clicked the 'back' button or linked back to the previous page using
other navigation.), remove the last page from the stack.
b) if the current page and the previous page are the same, assume the user
has linked to another website - don't modify the cookie.
c) if the user links directly back to the home or spash page, remove all
elements from visitor_path except that page.
d) if the user clicks on any other page, add that data to the top of the
stack (visitor_path).
3) Write the new changes to the cookie.
4) Construct the HTML for the breadcumbs: (Label + Link + separator) and
write the result to the innerHTML of the page's element where the breadcrumb
is to be placed. (NOTE: all pages on the site must use the same id or name
for this element).

That's it. Is it doable? Is a session cookie available to Javascript on
every visited page in the site?

Having said all, and assuming that it is doable, I leave it up to a more
experienced, creative Javascipt programmer to figure out all the bits and
pieces. I am going to read and learn more as well and attempt to implement
it. Lets see what happens!


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Latest member

Latest Threads