One of the Projects I am working on, I have to display SharePoint site name on a SharePoint library default edit form, I am using below code from tech net but it does not work, can someone please help me out to correct this and make it to work.
<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>
I am dynamically trying to display the site name on a share point library upload (default edit form) so users get to see what site they are working on and this has to be dynamic in nature which is why I am using JSOM approach.
FYI, I am working with SharePoint online. Thanks in advance.