Monday, January 28, 2013

Display current site name in Content Editor Web Part using JavaScript

Add the following script in a Content Editor Web Part


<script language="javascript" type="text/javascript">
_spBodyOnLoadFunctionNames.push("GetSiteName");

function GetSiteName(){
  var SiteName = document.getElementById('ctl00_PlaceHolderSiteName_onetidProjectPropertyTitle').innerHTML;//get the ID from 'view source' page
document.getElementById('lblsitename').innerHTML = SiteName;
}
</script>
<html>
<label id="lblsitename"></label>
</html></div>






1 comment: