You can do it without any SharePoint calls by using the default JavaScript location object (W3schools) and the page variable _spPageContextInfo_spPageContextInfo
(Ted Pattison's Blog).
Something like:
var url = window.location.protocol + "//" + window.location.host + _spPageContextInfo.siteServerRelativeUrl;
var url = window.location.protocol + "//" + window.location.host + _spPageContextInfo.siteServerRelativeUrl;