Get ClientContext using URL

javascript, jquery, sharepoint

Solution

`get_current()` would always return current context only. If you want to get context of particular site then you would need to pass url in `ClientContext()` method.

var context = new SP.ClientContext(URL);

In case you want to get root site context then you can directly use `get_root()` method.

Problem

In Sharepoint, when we load the sp.js file after that when we use given code then it gives the current site context. But how can i get the site context using url. ``` var context = new SP.ClientContext.get_current(); ```

Original source