문제

I want to hide a "div" from all startpages/welcomepages. But I cant just compare "start.aspx" and my url parameter cause sometimes the page "start.aspx" isn't there in the url. Is there a way to know if I'm on a "startpage" or not using javascript?

도움이 되었습니까?

해결책 2

Thanks for the help, unfortunately it didnt work for me since there where something wrong with my SP.Publishing reference.

Instead I fixed it with this code:

$(document).ready(function () {
   if (window.location.href.indexOf("_layouts") > -1) {
       $(".ms-breadcrumb-top").show()
   }
   else {
       $(".ms-breadcrumb-top").hide();
   }
}

All pages accept welcomepages are located in the _layouts for me so I'll just hide my element if it's not in the _layouts folder. Works like a charm so far.

다른 팁

SPWeb has RootFolder which internally has WelcomePage property. You can use that to get this information

var clientContext = new SP.ClientContext.get_current();
var spWeb = clientContext.get_web();
var rootFolder = spWeb.get_rootFolder();
clientContext.load(rootFolder, 'WelcomePage');
clientContext.executeQueryAsync(Function.createDelegate(this, onQuerySucceeded), Function.createDelegate(this, onQueryFailed));

function onQuerySucceeded() {
    alert(rootFolder.get_welcomePage());
}

function onQueryFailed(sender, args) {
    alert('error');
}

In case of publishing web

var web = context.get_web();
var pubWeb = SP.Publishing.PublishingWeb.getPublishingWeb(context, web);
context.load(pubWeb, 'DefaultPage');
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top