Get ClientContext using URL
12,408
Solution 1
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.
Solution 2
Try this
var context = new SP.ClientContext(URL);
Author by
Ravi Verma
I'm the one who lurks on SO correcting questions and answers and commenting on them. #SOreadytohelp
Updated on June 14, 2022Comments
-
Ravi Verma almost 2 years
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();