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?
Thanks
Jason
Hello Jason,
Try below code
$(document).on('knack-scene-render.any', function (event, view) {
var newUrl = "https://google.com";
$("#knack-logo a").attr("href", newUrl);
});
Thanks,
Sunny Singla
ssingla1985@gmail.com
+919855089359
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);
});
1 Like
This work great thanks Sunny.
How would I alter the code to remove the link altogether?
Hello Craig,
You need to find all links with there CSS selector or ID and replace URL
Regards,
Sunny Singla
Hi Craig
If you copy this code to your builder it should work.
Knack.router.on('route:viewScene', function () {
$('#knack-logo a').removeAttr('href');
});
Craig
Thanks Craig,
Works great.
1 Like