SP. Propiedad ClientContext.current (Object sp.js)

Obtiene el contexto de cliente actual del tiempo de ejecución del modelo de objetos de cliente (CSOM).

Última modificación: martes, 25 de junio de 2013

Hace referencia a: apps for SharePoint | SharePoint Foundation 2013 | SharePoint Server 2013

var value = SP.ClientContext.get_current()

Valor devuelto

Tipo: SP ClientContext
el contexto de cliente actual.

Ejemplo

var clientContext;
var website;

// Make sure the SharePoint script file 'sp.js' is loaded before your
// code runs.
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', sharePointReady);

// Create an instance of the current context.
function sharePointReady() {
    clientContext = SP.ClientContext.get_current();
    website = clientContext.get_web();

    clientContext.load(website);
    clientContext.executeQueryAsync(onRequestSucceeded, onRequestFailed);
}
function onRequestSucceeded() {
    alert(website.get_url());
}
function onRequestFailed(sender, args) {
    alert('Error: ' + args.get_message());
}