Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SPContext.Current.Site.ServerRelativeUrl : if == "/"
- var clientContext;
- var siteCollection;
- // 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 and get the site collection.
- function sharePointReady() {
- clientContext = SP.ClientContext.get_current();
- siteCollection = clientContext.get_site();
- clientContext.load(siteCollection);
- clientContext.executeQueryAsync(onRequestSucceeded, onRequestFailed);
- }
- function onRequestSucceeded() {
- alert('URL of the root website: ' + siteCollection.get_url());
- }
- function onRequestFailed(sender, args) {
- alert('Error: ' + args.get_message());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement