Share via


SP. Propriété ClientContext.web (sp.js)

Obtient le site web associé au contexte client.

**Dernière modification :**mardi 25 juin 2013

**S’applique à :**apps for SharePoint | SharePoint Foundation 2013 | SharePoint Server 2013

var value = SP.ClientContext.get_web()

Valeur renvoyée

Type : SP Web
le site Web qui est associé au contexte client.

Exemple

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 and get the website.
function sharePointReady() {
    clientContext = SP.ClientContext.get_current();
    website = clientContext.get_web();

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

Voir aussi

Autres ressources

Objet SP.ClientContext (sp.js)