<%-- breadcrumb --%>
<div class="loop-breadcrumb">
<div id='javascript-breadcrumb'
class='selected'></div>
</div>
<%-- /breadcrumb --%>
<script type="text/javascript">
if (document.addEventListener) {
document.addEventListener('DOMContentLoaded',
function () {
EnsureScriptFunc('sp.js', 'SP.ClientContext', JavascriptBreadcrumb);
}, false);
} else {
window.setTimeout(function () {
EnsureScriptFunc('sp.js', 'SP.ClientContext', JavascriptBreadcrumb);
}, 0);
}
function JavascriptBreadcrumb() {
if (_spPageContextInfo.pageListId !== null && _spPageContextInfo.pageListId !==
undefined)
// Retrieve the breadcrumb element
this.elm = document.getElementById('javascript-breadcrumb');
if (_spPageContextInfo.pageListId !== null && _spPageContextInfo.pageListId !==
undefined) {
var path = window.location.pathname;
var breadcrumbpth = "";
var bredname = "";
var separated = path.split("/");
for (var
i = 0, length = separated.length - 1; i < length; i++) {
if (i > 2) {
bredname += "/" + separated[i];
var webAbsoluteUrl = _spPageContextInfo.webAbsoluteUrl;
breadcrumbpth += " > " + "<a
href=" + webAbsoluteUrl + ""
+ bredname + ">" + separated[i]
+ "</a>";
}
if (length == 3) {
breadcrumbpth = " > " + document.title;
}
}
var titl = document.title.split('-');
if (titl[1] != undefined) {
titl = " > " +
document.title.split('-')[1];
}
else {
titl = "";
}
// Add the current site link to the
breadcrumb
var breadcrumburl = breadcrumbpth;
this.breadcrumb = "<a href='" + _spPageContextInfo.webAbsoluteUrl
+ "' >" +
_spPageContextInfo.webTitle + "</a></span><span
style='font-style:italic;'>" + breadcrumburl + "</span><span
style='font-style:italic;'>" + titl + "</span>";
this.elm.innerHTML = this.breadcrumb;
}
// Retrieve
the parent web of the current site
var clientContext = new
SP.ClientContext.get_current();
this.web = clientContext.get_web();
this.parentweb = this.web.get_parentWeb();
clientContext.load(this.parentweb);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySuccess),
Function.createDelegate(this, this.onCreationFail));
}
function onQuerySuccess() {
try {
// Check if the current web has a title,
if undefined, the top site has already been reached
if (this.parentweb.get_title()
!== undefined) {
// Add the parent site to the breadcrumb
this.breadcrumb = "<a href='" + this.parentweb.get_serverRelativeUrl()
+ "' style='color:#fff'>" + this.parentweb.get_title() + "</a>"
+ " > " + this.breadcrumb;
this.elm.innerHTML = this.breadcrumb;
alert(this.elm.innerHTML);
// Retrieve the parent its parent site
var clientContext = new SP.ClientContext(this.parentweb.get_serverRelativeUrl());
this.web = clientContext.get_web();
this.parentweb = this.web.get_parentWeb();
clientContext.load(this.parentweb);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySuccess),
Function.createDelegate(this, this.onCreationFail));
}
}
catch (e) { }
}
function onCreationFail() { }
</script>