Advertisement
Guest User

Untitled

a guest
May 2nd, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. SPContext.Current.Site.ServerRelativeUrl : if == "/"
  2.  
  3. var clientContext;
  4. var siteCollection;
  5.  
  6. // Make sure the SharePoint script file 'sp.js' is loaded before your
  7. // code runs.
  8. SP.SOD.executeFunc('sp.js', 'SP.ClientContext', sharePointReady);
  9.  
  10. // Create an instance of the current context and get the site collection.
  11. function sharePointReady() {
  12. clientContext = SP.ClientContext.get_current();
  13. siteCollection = clientContext.get_site();
  14.  
  15. clientContext.load(siteCollection);
  16. clientContext.executeQueryAsync(onRequestSucceeded, onRequestFailed);
  17. }
  18. function onRequestSucceeded() {
  19. alert('URL of the root website: ' + siteCollection.get_url());
  20. }
  21. function onRequestFailed(sender, args) {
  22. alert('Error: ' + args.get_message());
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement