SP. Propiedad ClientContext.site (Object sp.js)
Obtiene la colección de sitios asociada con el contexto de cliente.
Ú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_site()
Valor devuelto
Tipo: SP Sitio
la colección de sitios que está asociada con el contexto de cliente.
Ejemplo
var clientContext;
var siteCollection;
// 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 and get the site collection.
function sharePointReady() {
clientContext = SP.ClientContext.get_current();
siteCollection = clientContext.get_site();
clientContext.load(siteCollection);
clientContext.executeQueryAsync(onRequestSucceeded, onRequestFailed);
}
function onRequestSucceeded() {
alert('URL of the root website: ' + siteCollection.get_url());
}
function onRequestFailed(sender, args) {
alert('Error: ' + args.get_message());
}