<script type="text/javascript">
ExecuteOrDelayUntilScriptLoaded(getWebSiteData, "sp.js");  
var context = null;  
var web = null;  
function getWebSiteData() {  
context = new SP.ClientContext.get_current();  
web = context.get_web();  
context.load(web);  
context.executeQueryAsync(Function.createDelegate(this, this.onSuccessMethod), Function.createDelegate(this, this.onFailureMethod));  
}  
function onSuccessMethod(sender, args) {  
alert('web title:' + web.get_title() + '\n ID:' + web.get_id());  
}  
function onFaiureMethodl(sender, args) {  
alert('request failed ' + args.get_message() + '\n' + args.get_stackTrace());  
}  </script>