1

Is there any way to change the SharePoint 2013 logo dynamically, ideally via javascript?

I have tried:

document.getElementById("onetidHeadbnnr0").src="\path\image.png";   

Also tried:

 div = document.getElementById('onetidHeadbnnr2');
            div.setAttribute("LogoImageUrl", "\path\image.png;");

Both above are not working. I tried using an alert box to debug. There is some issue at the div.setAttribute for this control.

  • How are you executing it? Are you waiting for the DOM to be completed? – Robert Lindgren Mar 24 '14 at 6:06
  • Robert, I have a scirpt tag right before the closing head tag. How can I check if page is loaded using the _spBodyOnLoadFunctionNames? – variable Mar 24 '14 at 6:06
  • Are you writing this is inside document.ready? – Unnie Mar 24 '14 at 7:01
  • No I am using simple javascript. I am new to this. I am using <script> tags before closing head tag. – variable Mar 24 '14 at 7:02
  • Is this on premises or O365? If it's O365 just note that Microsoft has a track record of changing things like element IDs without notice, so what works today may not necessarily work tomorrow. A safer bet, since that's the only image in that area would be to scope a search to the class and then look for an img tag, as opposed to a specific ID. – webdes03 Jun 29 '14 at 13:08
1

which sharepoint logo were you trying to replace? Try the code below. It will replace the logo in the suitebar after the page has finished loading.

$(window).load(function() {

    //change suitebar logo hack
    var suitebar = $("#suiteBar");
    var branding = suitebar.find(".ms-core-brandingText");
    branding.html("<a href='/' title='Suitebar Logo'><img src='/_catalogs/masterpage/pathtoimage.png' height='30px'></a>");
});
  • the top left logo – variable Mar 25 '14 at 8:40
  • not the sharepoint text, the image (which you can otherwise chagne from look and feel – variable Mar 25 '14 at 9:12
0

I know I'm late on this, but it looks like you're using the wrong element ID. Try this:

document.getElementById("ctl00_onetidHeadbnnr2").src="http://path/to/image.png"; 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.