JSFiddle - React, Tailwind, and code Playground
by JInks Peng
JavaScript
function path() {
var items = location.pathname.substr(1).split('/');
var mainpath = '<a href = "' + location.protocol + '//' + location.hostname + '/';
var breadcurmbTrail = '<p>';
for(var i = 0; i < items.length; ++i) {
if(items[i].length === 0) break;
mainpath += items[i];
if(i < items.length-1) {
mainpath += '/';
}
if(i > 0 && i < items.length) {
breadcurmbTrail += '->';
}
breadcurmbTrail += mainpath +'"">' + items[i] + '</a>';
}
breadcurmbTrail += '</p>';
document.body.innerHTML = breadcurmbTrail;
}
path();