admin管理员组

文章数量:1296842

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

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();
Share asked Jan 29, 2014 at 13:37 Ravi VermaRavi Verma 1841 gold badge3 silver badges12 bronze badges 1
  • Can you helo me with this abut. Ihave exact same line, but it just don´t work. dev tool in Chrome says Uncaught errortype: undefined is not a function. ANy hint about it? – Ricker Silva Commented May 9, 2014 at 22:24
Add a ment  | 

2 Answers 2

Reset to default 5

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.

Try this

  var context = new SP.ClientContext(URL);

本文标签: javascriptGet ClientContext using URLStack Overflow