Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6608229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:35:15+00:00 2026-05-25T19:35:15+00:00

I am currently learning javascript/CSS and so I am trying to implement the Dynamic

  • 0

I am currently learning javascript/CSS and so I am trying to implement the Dynamic Javascript Breadcrumbs found at: http://www.webmonkey.com/2010/02/build_dynamic_breadcrumbs_with_javascript/. The code for that is below.

What I am trying to do is modify the links that the breadcrumbs generate; I would like them to be a shade of green and have no text-decoration whenever they are not active or being hovered over. When they are being active or hovered over, I would like them to turn red and become underlined.

The breadcrumbs are being generated correctly, but it seems like the CSS is not being applied correctly. The links are underlined no matter what and are blue to start with, then purple after they are visited. It is weird because if I modify the size, weight, font-family, etc of the links that gets applied, but not the color or text-decoration. I am probably making a beginner’s mistake somewhere, so thanks in advance for your time and help!

My CSS is:

.crumb{
  FONT-WEIGHT: medium;
  FONT-SIZE:medium;
  FONT-STYLE:italic;
  FONT-FAMILY:Arial;
}
.crumb:link, .crumb:visited{
  color: green;
  text-decoration: none;
}
.crumb:hover, .crumb:active: {
  color:red;
  text-decoration: underline;
}

The code for the breadcrumbs is:

var crumbsep = " > ";
var precrumb = "<span class=\"crumb\">";
var postcrumb = "</span>";
var sectionsep = "/";
var rootpath = "/"; // Use "/" for root of domain.
var rootname = "Home";

var ucfirst = 1; // if set to 1, makes "directory" default to "Directory"

var objurl = new Object;
objurl['main-default'] = 'Site Home';

// Grab the page's url and break it up into directory pieces
var pageurl = (new String(document.location));
var protocol = pageurl.substring(0, pageurl.indexOf("//") + 2);
pageurl = pageurl.replace(protocol, ""); // remove protocol from pageurl
var rooturl = pageurl.substring(0, pageurl.indexOf(rootpath) + rootpath.length);
if (rooturl.charAt(rooturl.length - 1) == "/") //remove trailing slash
{
  rooturl = rooturl.substring(0, rooturl.length - 1);
}
pageurl = pageurl.replace(rooturl, ""); // remove rooturl fro pageurl
if (pageurl.charAt(0) == '/') // remove beginning slash
{
  pageurl = pageurl.substring(1, pageurl.length);
}

var page_ar = pageurl.split(sectionsep);
var currenturl = protocol + rooturl;
var allbread = precrumb + "<a href=\"" + currenturl + "\">" + rootname + "</a>" +    
postcrumb; // start with root

for (i=0; i < page_ar.length-1; i++)
{
  var displayname = "";
  currenturl += "/" + page_ar[i];
  if (objurl[page_ar[i]])
  {
    displayname = objurl[page_ar[i]];
  }
  else
  {
    if (ucfirst == 1)
    {
      displayname = page_ar[i].charAt(0).toUpperCase() + page_ar[i].substring(1);
    }
    else
    {
      displayname = page_ar[i];
    }
   }
  allbread += crumbsep + precrumb + "<a href=\"" + currenturl + "\">" + displayname + 
    "</a>" + postcrumb;
}
document.write(allbread);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:35:15+00:00Added an answer on May 25, 2026 at 7:35 pm

    Probably not a javascript question. Firstly get the markup right, then work in generating it. The HTML result of the document.write is something like:

    <span class="crumb"><a href="...">linkText</a></span>
    

    The CSS should be something like:

    .crumb a {
      font-weight: medium;
      font-size: medium;
      font-style: italic;
      font-family: arial;
    }
    
    .crumb a:link, .crumb a:visited {
      color: green;
      text-decoration: none;
    }
    
    .crumb a:hover, .crumb a:active {
      color:red;
      text-decoration: underline;
    }
    

    There was an extra colon after .crumb a:active preventing it from applying. Works now.

    Incidentally, why are you doing this on the client with document.write when it would likely be far simpler to do it on the server and just send the HTML?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement a basic jQuery infinite carousel. As much for the learning
Currently I am mostly a PHP/Javascript/CSS/HTML applications programmer. But I would like to start
I'm learning Javascript and CSS and have run into an issue where my CSS
Currently, I am using Javascript - The Definitive Guide for learning Javascript from scratch.
I'm pretty new to JavaScript, which I am learning on my own. I'm currently
I'm new to Rails and i'm currently learning from tutorials from http://ruby.railstutorial.org/chapters/modeling-and-viewing-users-one#top find_by_email works
currently ironing out a way to parse the data of a page: http://www.foundationfinder.ch/ i
I currently learning about scrum and want to learn from experienced professionals in the
I'm currently learning Haskell, Which language (F# or Haskell) do you prefer for programming
So I am currently learning C++ and decided to make a program that tests

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.