ShinaShayesteh Posted December 19, 2022 Posted December 19, 2022 Hi everyone, weird question here, but is it possible to force the spyglass icon in the main navigation to link to a different website entirely? I work for a nonprofit that uses a Squarespace-based site for most of our content: https://www.strongtowns.org/ However, there is an auxiliary website we want to direct users to when they click the spyglass icon: https://actionlab.strongtowns.org/hc/en-us Is there a way to accomplish this (with code or otherwise)? I'd also love for the actual /search URL on our site to redirect to https://actionlab.strongtowns.org/hc/en-us. Right now, I have a code on the /search page that disables the search function, so it just appears as a blank page--which isn't ideal. Any advice would be greatly appreciated. Thank you!
tuanphan Posted December 21, 2022 Posted December 21, 2022 You mean Click Search icon >> redirect to actionlab.strongtowns.org/hc/en-us? The site uses Personal or Business or Commerce Plan? Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)
ShinaShayesteh Posted December 22, 2022 Author Posted December 22, 2022 Yes, precisely: we want that icon to link to actionlab.strongtowns.org/hc/en-us We're using the basic commerce plan (and we're on 7.0)
tuanphan Posted December 24, 2022 Posted December 24, 2022 On 12/22/2022 at 11:38 PM, ShinaShayesteh said: Yes, precisely: we want that icon to link to actionlab.strongtowns.org/hc/en-us We're using the basic commerce plan (and we're on 7.0) Hi, Can you enable search icon? I don't see it now we can use script code to force search icon open a custom url Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)
ShinaShayesteh Posted December 27, 2022 Author Posted December 27, 2022 Yes, sorry about that; we had disabled the icon temporarily over the holiday weekend. It should be visible now!
tuanphan Posted December 29, 2022 Posted December 29, 2022 On 12/27/2022 at 10:38 PM, ShinaShayesteh said: Yes, sorry about that; we had disabled the icon temporarily over the holiday weekend. It should be visible now! Add this to Last Line in Code Injection > Footer <script> $(document).ready(function() { $(".tweak-header-search-style-icon-only .Header-search").click(function() { var link = $(this).text(), href = "https://actionlab.strongtowns.org/hc/en-us"; window.location.href=href; }); }); </script> Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)
ShinaShayesteh Posted December 29, 2022 Author Posted December 29, 2022 It doesn't seem to be working, unfortunately? It still goes to the /search page, which we've disabled.
ShinaShayesteh Posted December 30, 2022 Author Posted December 30, 2022 Update! I've gotten it to sort of work by making these changes to the code: <script> $(document).ready(function() { $(".tweak-header-search-style-icon-only .Header-search").click(function() { window.open("https://actionlab.strongtowns.org/hc/en-us", "_blank"); }); }); </script> The spyglass does open the "Action Lab" website now, but in a new tab... Meanwhile, on the old tab, the user gets directed to a blank page (our old search page, now deactivated). Any ideas on how I can get the link to open in the same tab, instead of opening a new one?
creedon Posted December 30, 2022 Posted December 30, 2022 Try changing "_blank" to "_self". https://developer.mozilla.org/en-US/docs/Web/API/Window/open Let us know how it goes. Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.
ShinaShayesteh Posted December 30, 2022 Author Posted December 30, 2022 Tried it, and it didn't work, unfortunately! It wouldn't open the new link at all when it was "_self", so I changed it back to "_blank".
Solution creedon Posted December 30, 2022 Solution Posted December 30, 2022 Quote Tried it, and it didn't work Ah ha. The following should do the trick. <script> $( ( ) => { const selector = '.tweak-header-search-style-icon-only .Header-search'; $( selector ).click ( function ( event ) { location = 'https://actionlab.strongtowns.org/hc/en-us'; event.preventDefault ( ); } ); } ); </script> The trick here is that you need to prevent the events from the built-in SS code from firing. Let us know how it goes. tuanphan 1 Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.
ShinaShayesteh Posted January 3, 2023 Author Posted January 3, 2023 That worked perfectly, thank you so much!!! creedon and tuanphan 1 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment