1

We have masterpage which is set programatically to all sites on all site collections.

On masterpage we want to redirect user based on a value to a page in layouts folder.

I have read that the layout folder is common to all users. So of I hardcode a particular url/layouts/filepath then it might throw access denied error based on user permission.

So I want to get the current site url then I will appends /layouts/filepath to this url.

1

You could utilize SP.Utilities.Utility.getLayoutsPageUrl(pageName) Method from SharePoint JavaScript Library to return the URL to the page in the _layouts folder relative to the root of the website.

Example:

var pageUrl = SP.Utilities.Utility.getLayoutsPageUrl("Settings.aspx");
  • i tried using this in alert box but the box didnt comeup – variable Apr 4 '14 at 4:52
0

You can retrieve info about the current page from the object _spPageContextInfo injected in every page by SharePoint.

The current site(web) relative url is:

_spPageContextInfo.webServerRelativeUrl

There are other interesting properties, just fire open your browser developer toolbar console to find out more.

  • I have nasterpage that is common to all sites and all site collections. In that there is a link to policypage hrdcoded. – variable Apr 4 '14 at 4:11
  • So I want to make that link dynamic prefixing it with current site url so it never give error of access denied to users – variable Apr 4 '14 at 4:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.