SharePoint 2013 forums

Leave a comment

Below mentioned forums can be used for discussions/QnA about SharePoint 2013

SharePoint 2013 Preview for IT Professionals

Use this forum to ask questions and comment about SharePoint 2013 Preview as it pertains to setup, deployment, administration, and other IT Professional issues.

SharePoint 2013 Preview for Developers

Use this forum to ask questions and comment about SharePoint 2013 Preview as it pertains to development, customization, and other Developer issues.

Developing Apps for SharePoint

Use this forum to ask questions and comment about developing apps for SharePoint 2013.

SharePoint current Site Collection or site URL in JavaScript

1 Comment

SharePoint current Site Collection or site URL in JavaScript

In Sandbox Solutions or Office 365, many times you need to get the URL of the current site to use in JavaScript.

With the ECMAScript Client Object Model, there are multiple ways to access the current site URL like SP.Site.get_url() for the Root site URL or SP.Web.get_serverRelativeUrl() for the relative url of the current site.

But for plain JavaScript code, there is an easier way to get the URL by using the OOB JavaScript variable L_Menu_BaseUrl which stores the URL of the current Web or the Subsite.

There are some more OOB Javascript variables which can be useful. 

L_Menu_LCID : This contains the LCID setting of the current site.

L_Menu_SiteTheme : This contains the theme name of the current site.

_spUserId : This contains the id of the current user.