SP.Web object

Represents a Microsoft SharePoint Foundation Web site.

Applies to: apps for SharePoint | SharePoint Foundation 2013 | SharePoint Server 2013

var object = new SP.Web()

Members

The Web object has the following members.

Constructor

The Web object has the following constructor.

Constructor

Description

Web

This member is reserved for internal use and is not intended to be used directly from your code.

Methods

The Web object has the following methods.

Method

Description

applyTheme

Applies the theme specified by the contents of each of the files specified in the arguments to the site.

applyWebTemplate

Applies the specified site definition or site template to the Web site that has no template applied to it.

deleteObject

Deletes the Web site.

doesPushNotificationSubscriberExist

Checks whether the push notification subscriber exist for the current user with the given device application instance ID.

doesUserHavePermissions

Returns whether the current user has the given set of permissions.

ensureUser

Checks whether the specified login name belongs to a valid user in the site. If the user doesn't exist, adds the user to the site.

getAppBdcCatalog

getAppBdcCatalogForAppInstance

getAppInstanceById

Retrieves an AppInstance installed on this Site.

getAppInstancesByProductId

Retrieves all AppInstances installed on this site that are instances of the specified App.

getAvailableWebTemplates

Returns a collection of site templates available for the site.

getCatalog

Gets the list template gallery, site template gallery, or Web Part gallery for the Web site.

getChanges

Returns the collection of all changes from the change log that have occurred within the scope of the site, based on the specified query.

getEntity

Gets the specified external content type in a line-of-business (LOB) system application.

getFileByServerRelativeUrl

Returns the file object located at the specified server-relative URL.

getFolderByServerRelativeUrl

Returns the folder object located at the specified server-relative URL.

getPushNotificationSubscriber

Gets the push notification subscriber over the site for the specified device application instance ID.

getPushNotificationSubscribersByArgs

Queries for the push notification subscribers over the site for the specified value of custom arguments. Null or empty custom arguments will return subscribers without any filtering.

getPushNotificationSubscribersByUser

Queries for the push notification subscribers over the site for the specified user.

getSubwebsForCurrentUser

Returns the collection of child sites of the current site based on the specified query.

getUserById

Returns the user corresponding to the specified member identifier for the current site.

getUserEffectivePermissions

Gets the effective permissions that the specified user has within the current application scope.

initPropertiesFromJson

loadAndInstallApp

Uploads and installs an app package to this site.

loadAndInstallAppInSpecifiedLocale

Uploads and installs an App package on the site in a specified locale.

loadApp

Uploads an App package and creates an instance from it.

mapToIcon

Returns the name of the image file for the icon that is used to represent the specified file.

registerPushNotificationSubscriber

Registers the subscriber for push notifications over the site. If the registration already exists, the service token is updated with the new value.

unregisterPushNotificationSubscriber

Unregisters the subscriber for push notifications from the site.

update

Updates the database with changes that are made to the Web site.

Properties

The Web object has the following properties.

Property

Description

allowDesignerForCurrentUser

Gets a value that specifies whether the current user is allowed to use a designer application to customize this site.

allowMasterPageEditingForCurrentUser

Gets a value that specifies whether the current user is allowed to edit the master page.

allowRevertFromTemplateForCurrentUser

Gets a value that specifies whether the current user is allowed to revert the site to a default site template.

allowRssFeeds

Gets a value that specifies whether the site allows RSS feeds.

allProperties

Gets a collection of metadata for the Web site.

appInstanceId

The instance Id of the App Instance that this web represents.

associatedMemberGroup

Gets or sets the group of users who have been given contribute permissions to the Web site.

associatedOwnerGroup

Gets or sets the associated owner group of the Web site.

associatedVisitorGroup

Gets or sets the associated visitor group of the Web site.

availableContentTypes

Gets the collection of all content types that apply to the current scope, including those of the current Web site, as well as any parent Web sites.

availableFields

Gets a value that specifies the collection of all fields available for the current scope, including those of the current site, as well as any parent sites.

configuration

Gets either the identifier (ID) of the site definition configuration that was used to create the site, or the ID of the site definition configuration from which the site template used to create the site was derived.

contentTypes

Gets the collection of content types for the Web site.

created

Gets a value that specifies when the site was created.

currentUser

Gets the current user of the site.

customMasterUrl

Gets or sets the URL for a custom master page file to apply to the website.

description

Gets or sets the description for the site.

documentLibraryCalloutOfficeWebAppPreviewersDisabled

Determines if the Document Library Callout's WAC previewers are enabled or not.

effectiveBasePermissions

Gets a value that specifies the effective permissions that are assigned to the current user.

enableMinimalDownload

Gets or sets a Boolean value that specifies whether the Web site should use Minimal Download Strategy.

eventReceivers

Gets the collection of event receiver definitions that are currently available on the website.

features

Gets a value that specifies the collection of features that are currently activated in the site.

fields

Gets the collection of field objects that represents all the fields in the Web site.

folders

Gets the collection of all first-level folders in the Web site.

id

Gets a value that specifies the site identifier for the site.

language

Gets a value that specifies the LCID for the language that is used on the site.

lastItemModifiedDate

Gets a value that specifies when an item was last modified in the site.

lists

Gets the collection of all lists that are contained in the Web site available to the current user based on the permissions of the current user.

listTemplates

Gets a value that specifies the collection of list definitions and list templates available for creating lists on the site.

masterUrl

Gets or sets the URL of the master page that is used for the website.

navigation

Gets a value that specifies the navigation structure on the site, including the Quick Launch area and the top navigation bar.

parentWeb

Gets the parent website of the specified website.

pushNotificationSubscribers

Gets the collection of push notification subscribers over the site.

quickLaunchEnabled

Gets or sets a value that specifies whether the Quick Launch area is enabled on the site.

recycleBin

Specifies the collection of recycle bin items of the recycle bin of the site.

recycleBinEnabled

Gets or sets a value that determines whether the recycle bin is enabled for the website.

regionalSettings

Gets the regional settings that are currently implemented on the website.

roleDefinitions

Gets the collection of role definitions for the Web site.

rootFolder

Gets the root folder for the Web site.

saveSiteAsTemplateEnabled

Gets or sets a Boolean value that specifies whether the Web site can be saved as a site template.

serverRelativeUrl

Gets or sets the server-relative URL for the Web site.

showUrlStructureForCurrentUser

Gets a value that specifies whether the current user is able to view the file system structure of this site.

siteGroups

Gets the collection of groups for the site collection.

siteUserInfoList

Gets the UserInfo list of the site collection that contains the Web site.

siteUsers

Gets the collection of all users that belong to the site collection.

supportedUILanguageIds

Specifies the language code identifiers (LCIDs) of the languages that are enabled for the site.

syndicationEnabled

Gets or sets a value that specifies whether the RSS feeds are enabled on the site.

themeInfo

The theming information for this site. This includes information like colors, fonts, border radii sizes etc.

title

Gets or sets the title for the Web site.

treeViewEnabled

Gets or sets value that specifies whether the tree view is enabled on the site.

uiVersion

Gets or sets the user interface (UI) version of the Web site.

uiVersionConfigurationEnabled

Gets or sets a value that specifies whether the settings UI for visual upgrade is shown or hidden.

url

Gets the absolute URL for the website.

userCustomActions

Gets a value that specifies the collection of user custom actions for the site.

webs

Gets a Web site collection object that represents all Web sites immediately beneath the Web site, excluding children of those Web sites.

webTemplate

Gets the name of the site definition or site template that was used to create the site.

workflowAssociations

Gets a value that specifies the collection of all workflow associations for the site.

workflowTemplates

Gets a value that specifies the collection of workflow templates associated with the site.

Example

The following example creates an input button on an application page that displays information about a subsite.

<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<script type="text/ecmascript" language="ecmascript">

    var targetWeb;

    function runCode() {
        // Specify a client context using the server-relative URL of the sub web, load the sub web, and call the ExecuteQueryAsync method.
        var clientContext = new SP.ClientContext('/MySubWeb');
        targetWeb = clientContext.get_web();
        clientContext.load(targetWeb);
        clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
    }

    function onQuerySucceeded() {
        // On success, use get_ property assessor methods to return the value of the Title, ID, Language, uiVersion, Description, and Created properties of the SP.Web object.
        var message = "Web retrieved:";
        message += "\n Title: " + targetWeb.get_title();
        message += "\n ID: " + targetWeb.get_id();
        message += "\n Language: " + targetWeb.get_language();
        message += "\n UI Version: " + targetWeb.get_uiVersion();
        message += "\n Description: " + targetWeb.get_description();
        message += "\n Created: " + targetWeb.get_created();
        alert(message);
    }

    function onQueryFailed(sender, args) {
        alert('Request failed. \nError: ' + args.get_message() + '\nStackTrace: ' + args.get_stackTrace());
    }

</script>

    <input id="Button1" type="button" value="Run Code" onclick="runCode()" />

</asp:Content>

REST resource endpoint

See Web resource for more information.

Endpoint URI structure

http://<sitecollection>/<site>/_api/web

HTTP requests

This resource supports the following HTTP commands:

DELETE syntax

DELETE http://<sitecollection>/<site>/_api/web

MERGE syntax

MERGE http://<sitecollection>/<site>/_api/web

POST syntax

POST http://<sitecollection>/<site>/_api/web

PUT syntax

PUT http://<sitecollection>/<site>/_api/web