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

I have tried:


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? Commented Mar 24, 2014 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
    Commented Mar 24, 2014 at 6:06
  • Are you writing this is inside document.ready?
    – Unnie
    Commented Mar 24, 2014 at 7:01
  • No I am using simple javascript. I am new to this. I am using <script> tags before closing head tag.
    – variable
    Commented Mar 24, 2014 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
    Commented Jun 29, 2014 at 13:08

2 Answers 2


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
    Commented Mar 25, 2014 at 8:40
  • not the sharepoint text, the image (which you can otherwise chagne from look and feel
    – variable
    Commented Mar 25, 2014 at 9:12

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


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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