samedi 7 mars 2015

How to use javascript to create breadcrumbs?

I'm new to javascript and so I know I'm missing something, but I just cannot tell what it is that I'm missing.


I'm creating a widget for Adobe Muse and i'm wanting to make it possible for a user to add or remove breadcrumbs inside the widget. The widget allows a user to set a true or a false value and I'm using the document.write function to write the code. The widget uses schema.org markup hence the itemprop itemscope whatnot.


Here's what the script looks like



<script type="text/javascript">
var crumb2 = "true";
var crumb3 = "true";
if (crumb2 == "true") {
document.write("<span>Crumb2</span><span itemscope itemtype='http://ift.tt/WkMff0'><a href='crumb2.html' itemprop='url'><span itemprop='title'>Crumb2 Title</span></a></span>");
} else if (crumb3 == "true") {
document.write("<span>Crumb3</span><span itemscope itemtype='http://ift.tt/WkMff0'><a href='crumb3.html' itemprop='url'><span itemprop='title'>Crumb3 Title</span></a></span>");
}
</script>


From what I think I understand, once the first variable is read as true, it will ignore the rest of the variables (at least when the code is written in the way I have written it). Assuming that this is true, how can I get it to not do that (for lack of correct terminology)?


Aucun commentaire:

Enregistrer un commentaire