Questions tagged [javascript]

Javascript is a dynamic computer programming language, most commonly used as part of web browsers, whose implementations allow client-side scripts to interact with the user, control the browser, communicate asynchronously, and alter the document content that is displayed.

SharePoint extensively uses JavaScript, to work with data and user interfaces. JavaScript is heavily used in all versions of SharePoint and makes up over 70% of a page load, also JavaScript in SharePoint is becoming more integral, especially from version 15. (SharePoint 2013). With Apps becoming mainstream, we will see an ever increasing rise in the requirement of JavaScript for SharePoint.

You can find the detailed javascript documentation, here.

Questions having the tag regard all aspects of JavaScript in SharePoint and Apps, under all SharePoint SKUs.

5364 questions
40
votes
4 answers

SP.SOD how to use correctly?

SP.SOD is a nice feature of SharePoint, but how should I use it? For example, I use these lines of code ExecuteOrDelayUntilScriptLoaded(function () { //code }, "custom.js"); If I understand correctly this code will be invoked when custom.js is…
Alexander
  • 8,139
  • 2
  • 27
  • 42
17
votes
4 answers

Get the current UI language with ECMAScript

Is it possible to get the display language from within ECMAScript? Similar to Get the current UI language from a webpart, I'd like to get the user's display language, however I want to access it with the Client Object Model in JavaScript…
Modery
  • 547
  • 2
  • 6
  • 16
16
votes
5 answers

Can I tell what version of SharePoint is being used from JavaScript?

I have some static JavaScript being rendered to a page and would like it to behave differently if the version of SharePoint it is being displayed by is 2013. Can I tell what version of SharePoint is being used? The reason behind this request is…
Stu Pegg
  • 4,623
  • 7
  • 48
  • 91
15
votes
3 answers

color code in SharePoint calendar

I have SharePoint calendar and I want the entries to be in color based on status. If user add one entry and status is initially pending then that task would be in green, later it get changed to in progress then task color should change to yellow and…
Brishal
  • 1,205
  • 11
  • 42
  • 59
14
votes
9 answers

Getting a count of list items in a list via ECMAScript

I have a SharePoint 2010 web site with a master page that has a counter on it. I'm trying to update that counter using the ECMAScript. The code I have falls nicely into the success method - but I cannot find the right call to get a count. I have…
grimorde
  • 547
  • 2
  • 6
  • 20
13
votes
2 answers

How to return a value using context.executeQueryAsync?

How can I get this function to return the value? In all the examples I have seen, folks use an alert in the delegate functions, but I need to return the value instead. When I call the function, it fetches me my default string, which means the…
bgmCoder
  • 3,581
  • 16
  • 61
  • 102
12
votes
3 answers

SP.ClientContext.get_current() returning undefined objects

I am trying to get some information about the current context through the sharepoint javascript object model and am getting annoying errors. $(document).ready(function () { ExecuteOrDelayUntilScriptLoaded(loadConstants, "sp.js"); }); function…
user5907
11
votes
2 answers

Sharepoint 2013 - show ribbon to admin only

Is there a tutorial or specific bit of code I can use to hide the ribbon for all users except admins or a user group? This needs to be for sharepoint 2013 (rather than 2010) Can anyone help please?
uatonly
  • 363
  • 2
  • 11
9
votes
3 answers

ExecuteOrDelayUntillScriptLoaded(codetorun,SP.js) for entire script function

If you look at below code, I have used executeordelayuntillscriptloaded at start of my script so that it will run only after that file is loaded. But this breaks some functionality. Can you check this code and tell me if its not good practice? It…
variable
  • 4,473
  • 13
  • 75
  • 139
7
votes
1 answer

Are the SP.js and SP.UserProfiles.js preloaded in SharePoint?

I am using the javascript object model on the master page to fetch user profile properties. Do I need to use the foll. script tags for the code to work or are they optional?
variable
  • 4,473
  • 13
  • 75
  • 139
6
votes
3 answers

Can I run javascript based d3js.org on Sharepoint?

I'd like to try using D3.js and have access to microsoft hosted SharePoint sites. Is this possible? Where do I start on the Sharepoint side? Specifically, where can I put the .js files and the html files that will call the .js files via the…
Alex
  • 235
  • 3
  • 9
6
votes
5 answers

SP.ClientContext is not a Constructor

I keep receiving the error message "SP.ClientContext is not a Constructor" every time I try to use it in my JS code. After doing a bit of research online, I found SP.SOD.execute function(). However, I can't figure out if I am using it wrong, or if…
jobrien9
  • 147
  • 2
  • 4
  • 10
5
votes
1 answer

Set Yes/No field on selected list items by clicking a button

The functions I need are not complex but I did not succeded to make it work on my sharepoint, hence my posting here. I have a list of items and a Yes/No column. I want that the user get the possibility to select multiple items and by clicking a…
MüdeFuchs
  • 103
  • 1
  • 9
5
votes
1 answer

Difference between SP.SOD.executeFunc & other methods

I am confused about the idea of SP.SOD.executeFunc and other ways of referencing JavaScript, like: SP.SOD.execute SP.SOD.executeFunc ExecuteOrDelayUntilScriptLoaded SP.SOD.executeOrDelayUntilScriptLoaded LoadSodByKey I have read this post: What…
Julien Pierre
  • 71
  • 1
  • 3
5
votes
3 answers

sharepoint 2010 javascript get items from a document library

I am trying to use JavaScript to get all the items in a document library. I am able to get it to work, but for the life of me I cannot get the title, name or path to the file to come back. I can get ID, modified and any other custom columns I have…
lovejotd
  • 53
  • 1
  • 1
  • 3
1
2 3
10 11