SP へClientContext オブジェクト (sp.js)

サイトのユーザー カスタム アクションのコレクションを示す値を取得します。

**適用対象:**apps for SharePoint | SharePoint Foundation 2013 | SharePoint Server 2013

var object = new SP.ClientContext()

メンバー

ClientContextオブジェクトでは、次のメンバーがあります。

Constructor

ClientContextオブジェクトでは、次のコンスがあります。

コンストラクター

説明

ClientContext

Initializes a new instance of the ClientContext object for the specified SharePoint site.

メソッド

ClientContextオブジェクトでは、次の方法があります。

メソッド

説明

castTo

Casts the specified client object to a derived type.

破棄

Disposes of the context.

executeQueryAsync

Executes the current pending request asynchronously on the server.

読み込み時

Retrieves the properties of a client object from the server.

loadQuery

Retrieves an enumerable sequence of child client objects from the specified collection.

onExecutingWebRequest

Raises the ExecutingWebRequest event.

parseObjectFromJsonString

Parses the specified JavaScript Object Notation (JSON) string and gets an object from it.

プロパティ

ClientContextオブジェクトでは、次のプロパティがあります。

プロパティ

説明

applicationName

Gets or sets the name of the runtime where the current client application is located.

現在

Gets the current client context of the client-side object model (CSOM) runtime.

formDigestHandlingEnabled

Gets or sets a value that indicates whether form digest handling is enabled.

hasPendingRequest

Gets a value that indicates whether the client context has a pending request.

pendingRequest

Gets the client request that is sent to the server when the next executeQueryAsync method is executed.

requestTimeout

Gets or sets the request timeout in milliseconds

serverLibraryVersion

Gets the build version of Microsoft.SharePoint.Client.ServerRuntime.dll on the server.

serverSchemaVersion

Gets the schema version of Microsoft.SharePoint.Client.ServerRuntime.dll on the server.

serverVersion

Gets the version of the current instance of SharePoint 2013.

サイト

Gets the site collection that is associated with the client context.

traceCorrelationId

Gets or sets the trace correlation ID used by the server.

url

Gets the URL associated with the runtime context.

web

Gets the website that is associated with the client context.

注釈

コンテキストについては、現在の web アプリケーション、サイト、サイト コレクション、またはサーバー側のバージョンに戻るには、 ClientContextオブジェクトを使用します。

次の例では、SharePoint オブジェクト モデルにアクセスするためのクライアントのコンテキスト オブジェクトのインスタンスを作成します。例では、 currentプロパティを使用して、現在のコンテキストを取得します。

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());
}

関連項目

その他の技術情報

SharePoint 2013 の JavaScript ライブラリ コードを使用して基本的な操作を完了する