TrademarkTours Posted December 3, 2021 Share Posted December 3, 2021 Site URL: https://www.trademarktours.com/hmc On our site we use the button in the header to send people to a booking page. For this one specific page on my site, I want that button to take them to a different booking page. Can I accomplish this with a header injection code? (So far I've only succeeded in adding an extra design-less button rather than changing the existing button) Link to comment
Solution Beyondspace Posted December 4, 2021 Solution Share Posted December 4, 2021 15 hours ago, TrademarkTours said: Site URL: https://www.trademarktours.com/hmc On our site we use the button in the header to send people to a booking page. For this one specific page on my site, I want that button to take them to a different booking page. Can I accomplish this with a header injection code? (So far I've only succeeded in adding an extra design-less button rather than changing the existing button) Try adding to Home > Settings > Advanced > Code injection, footer <script> (function() { document.addEventListener('DOMContentLoaded',() => { document.querySelector('#collection-619679f0e67cea457538c10c .header-actions--right .header-actions-action--cta a').setAttribute('href','/home'); }) })() </script> Change the '/home' with the slug/url you want to redirect Let me know how it works on your site Press 👍 or mark this answer as solution to help another one too tuanphan 1 Greeting, it's BeyondSpace, I am Squarespace dev focus on provide solutions to enhance feature that squarespace.com can't provide.Feel free to check my current Squarespace Plugins Developement: Enable Pinch/Zoom on lightbox, Delivery Date Picker, Lightbox Studio pluginIf you find my answer fit your need, let's leave a like or upvote so others with the same issue can find their solution. Thank you Link to comment
TrademarkTours Posted December 5, 2021 Author Share Posted December 5, 2021 This was perfect, exactly what I was looking for! Would you be able to tell me how you got the collection # so I can attempt this on some other pages? Link to comment
Beyondspace Posted December 5, 2021 Share Posted December 5, 2021 (edited) You can use the chrorme exxtension: Squarespace ID Finder Here is how to find the page id: http://recordit.co/qwnj09oNCa Hope that it can help you Edited December 5, 2021 by bangank36 Greeting, it's BeyondSpace, I am Squarespace dev focus on provide solutions to enhance feature that squarespace.com can't provide.Feel free to check my current Squarespace Plugins Developement: Enable Pinch/Zoom on lightbox, Delivery Date Picker, Lightbox Studio pluginIf you find my answer fit your need, let's leave a like or upvote so others with the same issue can find their solution. Thank you Link to comment
TrademarkTours Posted December 5, 2021 Author Share Posted December 5, 2021 Amazing, you rock! Thanks very much for all your help Link to comment
ekspohz Posted January 16, 2022 Share Posted January 16, 2022 Hi @bangank36 I am trying to accomplish the same thing with the button in the navigation at https://www.museoutdoors.com/get-started - I would like to redirect it to a different page. I think the code is different given this page is on Brine. Could you advise? Thanks! Link to comment
tuanphan Posted January 17, 2022 Share Posted January 17, 2022 @ekspohz Try this adjusted code <script> (function() { document.addEventListener('DOMContentLoaded',() => { document.querySelector('#collection-61d9dcf755b23e793054204b .Header-nav--secondary a').setAttribute('href','/home'); }) })() </script> ekspohz 1 Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message How to: Setup Password & Share url - Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care Link to comment
ekspohz Posted January 18, 2022 Share Posted January 18, 2022 17 hours ago, tuanphan said: @ekspohz Try this adjusted code <script> (function() { document.addEventListener('DOMContentLoaded',() => { document.querySelector('#collection-61d9dcf755b23e793054204b .Header-nav--secondary a').setAttribute('href','/home'); }) })() </script> Perfect! Thank you @tuanphan Beyondspace and tuanphan 2 Link to comment
nathan.j.p Posted March 1 Share Posted March 1 Is there a way to change the text of the button as well as the href link location? Link to comment
tuanphan Posted March 6 Share Posted March 6 On 3/1/2023 at 11:27 PM, nathan.j.p said: Is there a way to change the text of the button as well as the href link location? Header button or? All pages or which page? Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message How to: Setup Password & Share url - Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care Link to comment
nathan.j.p Posted March 14 Share Posted March 14 On 3/5/2023 at 6:00 PM, tuanphan said: Header button or? All pages or which page? The header button on each service page. For example: On service page 1 I want the header button to say "Book Service 1" and link to the next step in the booking process for that service. On service page 2 I want the header button to say "Book Service 2" and link to the next step in the booking process for that service. So I just need to know how to target and change the header button text, and the header button href link location per page. I'm assuming I'll have to use some javascript in settings>advanced>code injection which I know how to do. I just don't know how to target the header button specifically. Thank you @tuanphan Link to comment
tuanphan Posted March 18 Share Posted March 18 On 3/15/2023 at 3:24 AM, nathan.j.p said: The header button on each service page. For example: On service page 1 I want the header button to say "Book Service 1" and link to the next step in the booking process for that service. On service page 2 I want the header button to say "Book Service 2" and link to the next step in the booking process for that service. So I just need to know how to target and change the header button text, and the header button href link location per page. I'm assuming I'll have to use some javascript in settings>advanced>code injection which I know how to do. I just don't know how to target the header button specifically. Thank you @tuanphan Hi, Yes. This is possible. Can you share link to a service page? We can check & give code easier Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message How to: Setup Password & Share url - Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care Link to comment
nathan.j.p Posted March 18 Share Posted March 18 Sure, we just have basic service pages set up for now. You can go to Mothershipfitness.com. Thanks @tuanphan Link to comment
tuanphan Posted March 20 Share Posted March 20 On 3/18/2023 at 10:20 PM, nathan.j.p said: Sure, we just have basic service pages set up for now. You can go to Mothershipfitness.com. Thanks @tuanphan Add to Page Header <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("header#header a.btn").html(function() { return $(this).html().replace("Start training for free", "new text"); }); $("header#header a.btn").attr('href','https://google.com'); }); </script> nathan.j.p 1 Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message How to: Setup Password & Share url - Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care Link to comment
nathan.j.p Posted March 20 Share Posted March 20 2 hours ago, tuanphan said: Add to Page Header <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("header#header a.btn").html(function() { return $(this).html().replace("Start training for free", "new text"); }); $("header#header a.btn").attr('href','https://google.com'); }); </script> @tuanphan This is awesome! Works perfectly. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment