# Change URL of Header Logo - Javascript

**URL:** <https://forums.knack.com/t/change-url-of-header-logo-javascript/9894>\
**Category:** Get Answers\
**Created:** [July 26, 2018, 6:07pm UTC](https://forums.knack.com/t/change-url-of-header-logo-javascript/9894 "2018-07-26T18:07:53Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![JasonSandl90577](https://avatars.discourse-cdn.com/v4/letter/j/eada6e/32.png) [@JasonSandl90577](https://forums.knack.com/u/JasonSandl90577)\
**Post date:** [July 26, 2018, 6:07pm UTC](https://forums.knack.com/t/change-url-of-header-logo-javascript/9894/1 "2018-07-26T18:07:53Z")

</div>

I want to change the link that is in the header area.

I don't see a place to change that in the app settings, so it seems I will need to use javascript to get this done.

Anyone have anything that will change the URL of the header logo?

&nbsp;

Thanks

Jason

---

<div class="post-metadata">

**Author:** ![JasonSandl90577](https://avatars.discourse-cdn.com/v4/letter/j/eada6e/32.png) [@JasonSandl90577](https://forums.knack.com/u/JasonSandl90577)\
**Post date:** [July 26, 2018, 6:22pm UTC](https://forums.knack.com/t/change-url-of-header-logo-javascript/9894/2 "2018-07-26T18:22:21Z")

</div>

Works perfect. Thanks!

---

<div class="post-metadata">

**Author:** ![Sunny\_Singla](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/sunny_singla/32/1007_2.png) [@Sunny\_Singla](https://forums.knack.com/u/Sunny_Singla)\
**Post date:** [July 26, 2018, 6:17pm UTC](https://forums.knack.com/t/change-url-of-header-logo-javascript/9894/3 "2018-07-26T18:17:16Z")

</div>

Hello Jason,

&nbsp;

Try below code

$(document).on('knack-scene-render.any', function (event, view) {  
 var newUrl = "[https://google.com](https://google.com)";  
 $("#knack-logo a").attr("href", newUrl);  
});

&nbsp;

Thanks,

Sunny Singla

[ssingla1985@gmail.com](mailto:ssingla1985@gmail.com)

+919855089359

---

<div class="post-metadata">

**Author:** ![hansolo](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/hansolo/32/4164_2.png) [@hansolo](https://forums.knack.com/u/hansolo)\
**Post date:** [July 5, 2024, 7:48pm UTC](https://forums.knack.com/t/change-url-of-header-logo-javascript/9894/4 "2024-07-05T19:48:41Z")

</div>

I would like to provide an update to this thread. For myself, I needed to make a slight change to Sunny’s suggestion for this code to work.

I needed to change “#knack-logo a” to “.knHeader\_\_title-logo-wrapper” for this to function properly.

$(document).on(‘knack-scene-render.any’, function (event, view) {  
var newUrl = “#example\_page”;  
$(“.knHeader\_\_title-logo-wrapper”).attr(“href”, newUrl);  
});

---

<div class="post-metadata">

**Author:** ![Craig\_Anderson](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/craig_anderson/32/1819_2.png) [@Craig\_Anderson](https://forums.knack.com/u/Craig_Anderson)\
**Post date:** [August 28, 2024, 7:57am UTC](https://forums.knack.com/t/change-url-of-header-logo-javascript/9894/5 "2024-08-28T07:57:12Z")

</div>

This work great thanks Sunny.  
How would I alter the code to remove the link altogether?

---

<div class="post-metadata">

**Author:** ![Sunny\_Singla](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/sunny_singla/32/1007_2.png) [@Sunny\_Singla](https://forums.knack.com/u/Sunny_Singla)\
**Post date:** [August 28, 2024, 8:06am UTC](https://forums.knack.com/t/change-url-of-header-logo-javascript/9894/6 "2024-08-28T08:06:39Z")

</div>

Hello Craig,

You need to find all links with there CSS selector or ID and replace URL

Regards,  
Sunny Singla

---

<div class="post-metadata">

**Author:** ![CSWinnall](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/cswinnall/32/3631_2.png) [@CSWinnall](https://forums.knack.com/u/CSWinnall)\
**Post date:** [August 29, 2024, 5:22pm UTC](https://forums.knack.com/t/change-url-of-header-logo-javascript/9894/7 "2024-08-29T17:22:10Z")

</div>

Hi Craig

If you copy this code to your builder it should work.

```auto
Knack.router.on('route:viewScene', function () {
        $('#knack-logo a').removeAttr('href');
});

```

Craig

---

<div class="post-metadata">

**Author:** ![Craig\_Anderson](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/craig_anderson/32/1819_2.png) [@Craig\_Anderson](https://forums.knack.com/u/Craig_Anderson)\
**Post date:** [August 31, 2024, 3:23pm UTC](https://forums.knack.com/t/change-url-of-header-logo-javascript/9894/8 "2024-08-31T15:23:30Z")

</div>

> [@CSWinnall](#):
>
> ```auto
> Knack.router.on('route:viewScene', function () {
> $('#knack-logo a').removeAttr('href');
> });
> 
> ```

Thanks Craig,  
Works great.

---

<div class="post-metadata">

**Author:** ![zackhz](https://avatars.discourse-cdn.com/v4/letter/z/48db29/32.png) [@zackhz](https://forums.knack.com/u/zackhz)\
**Post date:** [March 11, 2026, 11:10pm UTC](https://forums.knack.com/t/change-url-of-header-logo-javascript/9894/9 "2026-03-11T23:10:12Z")

</div>

adding this to the pile. (i’m not a coder but i asked the internet a favor and it whispered this back to me in exchange for the next generation’s ability to problem solve 🤗 ) My issue was that - occasionally/somehow - the link in the header logo was attempting to take the logged in user to a page that they don’t have access to because of their user role(s). I wanted to define the link based on the currently logged in user’s role(s). My app has 3 “admin” roles. (those roles are objects 26, 80, and 96 below.) All other roles are “user” roles.

```auto
(function () {
  function userHasAdminRole() {
    var user = Knack.getUserAttributes();
    if (!user || !user.roles || !user.roles.length) return false;

    var adminRoleKeys = ["object_26", "object_80", "object_96"];

    return user.roles.some(function (roleKey) {
      return adminRoleKeys.includes(String(roleKey));
    });
  }

  function setLogoHref() {
    var target = userHasAdminRole()
      ? “https://google.com/adminurl”
      : “https://google.com/userurl”;

    var $logo = $(".knHeader__title-logo-wrapper, #knack-logo a");

    if ($logo.length) {
      $logo.attr("href", target);
    }
  }

  $(document).on("knack-scene-render.any", function () {
    setLogoHref();
  });

  if (Knack.router && typeof Knack.router.on === "function") {
    Knack.router.on("route:viewScene", function () {
      setTimeout(setLogoHref, 0);
    });
  }
})();

```

No idea if it’s any good, but seems to work. I used adminRole but the var and function names can be changed to match your intent. i think you just to define the two urls, and define the user role objects that you want to send to the admin url. when the logo is clicked, if the logged in user’s role(s) match any of the defined objects, they’ll be sent to the top/admin url, and i think all others will go to the bottom/user url. feedback welcome.

---

<div class="post-metadata">

**Author:** ![Sophie](https://avatars.discourse-cdn.com/v4/letter/s/35a633/32.png) [@Sophie](https://forums.knack.com/u/Sophie)\
**Post date:** [March 23, 2026, 12:25pm UTC](https://forums.knack.com/t/change-url-of-header-logo-javascript/9894/10 "2026-03-23T12:25:11Z")

</div>

The default behavior for the Knack logo usually forces a redirect to the parent app page, but you can override this with a small script in the API & Code section. You need to target the logo selector specifically to prevent the default action.

Try to add this to your Javascript pane:

```auto
$($(document).on('knack-view-render.any', function(event, view, data) {
  var logoLink = $(".kn-header__logo a");
  if (logoLink.length) {
    logoLink.attr("href", "https://your-custom-url.com");
    logoLink.attr("target", "_blank"); // Optional: opens in a new tab
  }
}));

```

This approach waits for the view to render so the element is actually present in the DOM before the script tries to modify the attribute. It’s a cleaner way to handle it than a simple timeout, which can be hit or miss depending on the connection speed. If the logo is part of a specific scene, you can replace ‘any’ with the scene key to limit where the script runs.
