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.

learn more… | top users | synonyms (2)

37
votes
6answers
28k views

How do you get the current list item in JavaScript?

There's all kinds of ECMAScript class library examples around but all of the ones I find show how to retrieve all list items (through SP.ClientContent) but how do you get the current list item? I'm ...
31
votes
9answers
14k views

How do I know if the page is in Edit Mode from JavaScript?

Is there a way to find out if a page is in Edit Mode from JavaScript? I know in on the server-side can be found using SPContext.Current.FormContext.FormMode but I can't find any means of doing it ...
13
votes
1answer
2k views

Change Sharepoint language with a link?

Is there a way to get the language-switch control as static link in the pagelayout? I want my users to switch between German and English with a single click. Sorry guys, found a solution :D ...
12
votes
2answers
2k views

Cannot add custom web part to page using the JS OM

I'm trying to add a custom web part (that is one I have written myself) using the new Javascipt OM available with SharePoint 2010. My solution is also running within the Sandbox. I have it working ...
10
votes
2answers
721 views

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 ...
10
votes
4answers
9k views

SP.UI.ModalDialog.showModalDialog using the html option

http://msdn.microsoft.com/en-us/library/ff410058.aspx says that you can use the option html to display html text in a modal. I have a string like this; var html = ...
10
votes
3answers
3k views

Grab a specific property bag using ECMA script

I am trying to grab a key/value pair from a specific property bag but can't find any documentation or example code on how to grab a property bag. Currently I can only seem to grab allProperties. Here ...
9
votes
4answers
1k views

Why does having `windows.onload` break page editing?

This is related to an earlier question that I posted: Can't edit page after adding custom web part! Basically, I have created a web part with some javascript. When I add this web part to a ...
9
votes
2answers
8k views

Programmatically add JS/CSS to pages

I've created a Visual Studio SharePoint 2010 solution with an ASCX that adds some JavaScript files and CSS to the head of each page; this is based on this article. When I deploy the solution, it adds ...
9
votes
3answers
5k views

Get the current UI language with ECMAScript

Is it possible to get the display language from within ECMAScript? Similar to http://www.sharepointoverflow.com/questions/3129/get-the-current-ui-language-from-a-webpart, I'd like to get the user's ...
9
votes
10answers
3k views

Has anyone optimized the front-end (css/javascript files) of a SharePoint site

So it seems to be that Sharepoint's front-end optimization is non-existant. For example, http://dfs.us.dell.com/Pages/DFSHomePage.aspx, according to YSlow, is serving up 14 separate JavaScript files, ...
9
votes
4answers
2k views

SharePoint 2013 hide elements (in body area ) when ribbon is expanded / ribbon is in use

Is there a css class/id in SharePoint 2013 that hide elements when the ribbon is in use? I've got some elements that I don't want to show when the user's in edit mode! In the picture below you can ...
9
votes
1answer
476 views

Detecting browser and replacing web part?

I have a video I want to display on my SharePoint 2010 public facing site and at the moment I am using Silverlight, however, I would like to replace this with flash (youtube actually) if the users are ...
9
votes
3answers
11k views

How to get all items in a View using Client Object Model (JavaScript)

To get all the items in a List you use // Setup context & load web context = new SP.ClientContext.get_current(); web = context.get_web(); context.load(web); // Load task list this.List = ...
9
votes
3answers
3k views

Site Assets vs. Style Library

I usually store my JavaScript/jQuery files in the Site Assets library, but I see on forums that others are using the Style Library. What are the respective benefits of each?
9
votes
1answer
2k views

(Solved) Start a Workflow of the Host-Web via SharePoint App and JSOM

The Last Update is the Solution I have got an App for SharePoint 2013, which needs to start a Workflow. This Workflow is in the HostWebContext, not in the AppContext. The List, the Workflow is ...
9
votes
1answer
189 views

Passing args to QuickLinksDialog with JS

I have a small button on a site which when i press should start a QuickLinksDialog and fill in some of the fields there. Everything goes good and well except the fields (like: title and url) still ...
9
votes
4answers
3k views

“a is null” error in vanilla SP2010 install

I'm setting up an SP2010 VM for dev testing purposes. Our vanilla install has no other components present and is throwing JS errors in Chrome and Firefox. In Firefox (v13): a is null ...
8
votes
4answers
6k views

How to log off user from SharePoint site, if the user has been inactive for 20 minutes

How to log off the SharePoint site, if the user is has been inactive for for 20 minutes? Do I need to redirect user to logout page? How would I count the idle time?
8
votes
3answers
8k views

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 ...
8
votes
1answer
256 views

What does ULSxSy:; do in SharePoint JS files?

So I was going through init.js and sp.js and found out that nearly all of the SharePoint OOB JS functions start with the following line: "ULSxSy:;" For example: function ctxInitItemState(ctxCur) ...
7
votes
3answers
4k views

How to avoid caching issue when using custom JavaScript and CSS deployed under _layouts?

On our farm, I'm deploying some JavaScript and CSS files under the _layouts folder. I'm then referencing them, where it's required using a <SharePoint:ScriptLink> or a ...
7
votes
1answer
3k views

How to get a list of all Choice field options using Client Object Model

How would you get a list of all the possible choices from a choice field (e.g. Task list Priority or Status fields) using javascript client object model?
7
votes
1answer
504 views

JavaScript Client Object Model functionality to get all the non hidden lists of current web and listing them

We have requirement to get all the non hidden lists of current web using JavaScript Client Object Model(JSOM). I have tried the below code but failed to get the desired result. function ...
7
votes
2answers
1k views

How do you stop scroll position maintained after postback on lists?

I have a list with paging enabled and a page size of 10. When you scroll to the bottom of the page hit the next button in the list the page redirects to itself with different querystring parameters ...
7
votes
2answers
7k views

Adding ScriptLink for js file to my Visual Webpart causes error: “Cannot make a cache safe URL for…”

Full error: Cannot make a cache safe URL for "sprocketcomplete/layouts/sprocketcomplete/js/sprocketcomplete.js", file not found. Please verify that the file exists under the layouts ...
7
votes
2answers
730 views

How do I trigger the default form validation without submitting the form

I'm customizing the NewForm of a list item and need to trigger the default form validation from my JavaScript, but I don't want the form to be submitted, since I'm doing that in a callback later on. ...
7
votes
1answer
15k views

the property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested

The below question was based on this article: http://www.learningsharepoint.com/2011/09/10/get-all-folders-using-ecmascriptjavascript-client-object-model-sharepoint-2010/ I think the author there ...
7
votes
4answers
4k views

ExecuteOrDelayUntilScriptLoaded too slow in Firefox and Chrome

I want to use CSOM but waiting around 2 or 3 seconds after page load before I can even do my first query is crazy! See below. Using jQuery dom ready shows a reasonable ready time, but SP.ClientContext ...
7
votes
3answers
10k views

How can I use the SharePoint Javascript Object Model from a plain HTML page?

I would like to use the SharePoint Javascript Object Model from a "plain" html page (ie, not an .aspx application page etc.) Is this even possible? If so, what scripts should I reference? I've added ...
7
votes
1answer
1k views

Create a Document Library Item base on a ContentType with JavaScript Object Model (JSOM)

I'm trying to create a new item in my Entreprise Wiki Pages Document Library. It's associated with a News Content type. I was able to retrieve the SP.List object (myList), the SP.ContentType object ...
6
votes
3answers
487 views

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 ...
6
votes
3answers
9k views

Javascript to display sharepoint list items on page load

With Client Object Model API and a bit of javascript, I want to retrieve the items of a sharepoint list and display them into the web page, when the web page loads. I've successfully implemented ...
6
votes
1answer
3k views

How to get a value included from a lookup column using the javascript Client Object Model?

Related: How to retrieve a ListItem using the Javascript Client Object Model? In my previous question I was able to successfully retrieve a basic value from a list item. My problem is that I am now ...
6
votes
4answers
1k views

How to access a Web application/Farm level property bag via jQuery/Javascript/ClientContext

It it possible to access the Web application/Farm level property bag using jQuery/Javscript/ClientContext? If not, then what are the possible alternatives to access Web Application Farm level property ...
6
votes
3answers
5k views

How to get the ID of the list item just inserted using ecmascript

I am stuck at a place where I have to update a list which has a Lookup column. For example I am using this code to update my normal list var clientContext = SP.ClientContext.get_current(); ...
6
votes
1answer
2k views

Context Menus - Send To not working in IE9

I have a document center with a custom master page. The page is designed with IE9/HTML5/CSS3 in mind. In my other question, I worked out how to fix the IM Presence icons by fixing some core ...
6
votes
4answers
1k views

How can I disable the Document Library drag and drop function?

Before I start - I'm new to this SharePoint development lark and am slowly familiarising myself with it. We're using SharePoint online and I have amended the SharePoint out-of-the-box document ...
6
votes
1answer
676 views

Get and remove all currently displayed notifications from SP.UI.Notify

I am sending a variety of notifications via SP.UI.Notify.addNotification("blah", true); setting the "sticky bit" to true so that the notification stays visible. When I display a second ...
5
votes
4answers
14k views

Get Site Collection full URL using javascript

I want to get the URL for my site collection. One way I thought I could do it was using the window.location in javascript and getting it that way. I know that you can use ECMA script and the client ...
5
votes
4answers
6k views

Get current web url in a SPRibbon Custom Action Command

I've a SPRibbon custom action with the purpose of open an custom app page in a modal dialog, but I'm getting troubles for getting the current web URL, as well, set a reference for a .js with the right ...
5
votes
3answers
9k views

Cannot get field value of list item through JavaScript

I try to get the value of a list item (that is currently selected). I know that I must load it into the context but even with loading the field explicitly I get the following message. Microsoft ...
5
votes
8answers
19k views

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 ...
5
votes
1answer
462 views

structure of sharepoint javascript functions

I am trying to understand more the structure of javascript functions in SharePoint. Why does every function begin with som value than colon and semicolon like ULSrE8:; in spgridview.debug.js: ...
5
votes
7answers
5k views

What is the proper way to add jQuery to a MasterPage?

Currently I am using this method in the header: <script src="/_layouts/MNCAssets/scripts/jquery-1.5.1.min.js"></script> But for some reason, my webparts that use jQuery don't appear to ...
5
votes
6answers
10k views

How do I determine a user's SharePoint group membership using the client object model?

I want to redirect users from a landing page to another page in SharePoint 2010, based on their group membership. I need to do this using JavaScript (ECMAScript) and not server side code.
5
votes
2answers
842 views

how to set list alert using javascript in sharepoint 2010?

I need to set a list alert for current (logged in) user using javascript. var currentcontext = new SP.ClientContext.get_current(); var currentweb = currentcontext.get_web(); ...
5
votes
3answers
8k views

How to access list in SharePoint Hosted App?

I want to create an Sharepoint hosted app but how to access list in these App ??
5
votes
3answers
3k views

Can't upload a non-text file to SharePoint App via REST API

I am using the following REST code to add a file as an attachment to a SharePoint 2013 list item. <asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server"> <SharePoint:ScriptLink ...
5
votes
2answers
897 views

ScriptResx.ashx Not Working

I'm trying to use ScriptResx.ashx in an Application Page I'm building (just to test out the functionality) and every time I try to grab a resource from what should be a JavaScript object, SharePoint ...