Get Current SharePoint Site Url using javascript
<script>
var clientContext;
var website;
function GetSiteUrl()
{
clientContext = SP.ClientContext.get_current();
website = clientContext.get_web();
clientContext.load(website);
clientContext.executeQueryAsync(onRequestSucceeded, onRequestFailed);
}
function onRequestSucceeded() {
alert(website.get_url());
}
function onRequestFailed(sender, args) {
alert('Error: ' + args.get_message());
}
</script>
<a href='javascript:GetSiteUrl();'>Get URL</a>
var clientContext;
var website;
function GetSiteUrl()
{
clientContext = SP.ClientContext.get_current();
website = clientContext.get_web();
clientContext.load(website);
clientContext.executeQueryAsync(onRequestSucceeded, onRequestFailed);
}
function onRequestSucceeded() {
alert(website.get_url());
}
function onRequestFailed(sender, args) {
alert('Error: ' + args.get_message());
}
</script>
<a href='javascript:GetSiteUrl();'>Get URL</a>
Comments
Post a Comment