In this post I will explained how we can dynamically apply/change SharePoint 2010 site Header Image. Create Image library, add image named “SiteHeaderImg.png” and below code in master page
<script type="text/javascript">
function ChangeImage() {
function ChangeImage() {
try {
var URL_str = L_Menu_BaseUrl + '/ImageLibrary/SiteHeaderImg.png';
document.getElementById("s4-titlerow").style.background = "background-image: url('" + URL_str + "') no-repeat";
var URL_str = L_Menu_BaseUrl + '/ImageLibrary/SiteHeaderImg.png';
document.getElementById("s4-titlerow").style.background = "background-image: url('" + URL_str + "') no-repeat";
/* (Works in Firefox) */
document.getElementById("s4-titlerow").style.background = "url('../ImageLibrary/SiteHeaderImg.png') no-repeat";
document.getElementById("s4-titlerow").style.background = "url('../ImageLibrary/SiteHeaderImg.png') no-repeat";
}
catch (e) {
alert(e);
}
}
_spBodyOnLoadFunctionNames.push("ChangeImage()");
</script>
_spBodyOnLoadFunctionNames.push("ChangeImage()");
</script>
No comments:
Post a Comment