Couple of useful JavaScript global variables in SharePoint

July 24th, 2008 | Categories: JavaScript, SharePoint

If you’re using custom JavaScripts with SharePoint some global JavaScript variables may come in handy.

These variables work if you’re using SharePoint’s default or any other custom master page.

L_Menu_BaseUrl – the base URL of the site / subsite. Very useful when you need to determine the absolute path of the site in JavaScript. Example: document.location = L_Menu_BaseUrl + ‘lists/calendar/allitems.aspx’ //redirects to Calendar list

L_Menu_LCID – the LCID of the site you’re in. Useful if you need to determine the language of the site. The list of Locale IDs can be found here. I’m using the LCID for localizations in ERTE project. See the example of checking LCID below:

.
L_Menu_SiteTheme – the name of the theme applied to the site.

There is one more useful variable, but this one can’t be used on custom master pages that you created. This one is used in the SharePoint’s default pages:

_spUserId – the ID of the logged in user.

Oznake ponudnika Technorati: ,

  1. Rich Finn
    July 24th, 2008 at 16:36
    Reply | Quote | #1

    sweet!! great info for the ajax moss devs…

  2. Chris sammut
    September 2nd, 2008 at 08:22
    Reply | Quote | #2

    Hi,
    Is there a list of varibales available on the internet?
    For example I need to add in a field the current url of the site the user is in. however I can only find the base url.
    Cheers
    Chris Sammut