All things Shopify and commerce
Hi,
Is there a way I can create a menu item that links to an external site in a new window?
Thanks,
Paul
Solved! Go to the solution
This is an accepted solution.
Yea i think you could do that in the lliquid code if its not possible in the theme editor. Let me know if you need help with that
Hi,
Thanks, yes I do need some help. I just need that link to open in a new window.
Paul
Ok which theme are you using?
Brooklyn
Heres a quick fix throw this at the top of your theme.liquid file {%- if page.handle contains "test-page" -%}<script>window.open("https://apps.shopify.com/elevate-ab-testing", '_blank'); window.history.back();</script> {%- endif -%}
Replace the url i have with whatever url you want to open externally.
That doesn't work, maybe because the link is to a url outside of the shopify site.
Hey sorry i forgot to mention what i did was i made another page and added it to the navigation. When i click on that it has a url, i put the name of that url where test-page is. What you have to do is replace test-page with your url. Just the part after the yourstore.com/. Let me know if you still have any issues
Sorry I guess I am not getting it.
Here is the site https://heartofadragonmoviestore.com/
The BLOG in the menu goes to a blogger site, I would like that to open in a new window.
So i checked it out, how did you get it to go to the other link. Did you use what i sent or did you do it a different way?
A different way, I just put the url in the menu link box in the built in menu list. Now I want to open it in a new window.
Paul, try this.
Open your theme.js (or theme.js.liquid) asset and at the very bottom of the file add this code:
/* make all external links open in new window/tab */
$( function(){
$('a[href^="https://"]') // select all links wit non-realtive path
.not('[href^="'+ window.location.origin + '"]') // except for those on same site
.attr('target', "_blank") // make em open in new window
});
This is an accepted solution.
Hooray! You are a genius my man.
Thank you so much.
Paul
As 2024 wraps up, the dropshipping landscape is already shifting towards 2025's trends....
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024In today’s interview, we sat down with @BSS-Commerce to discuss practical strategies f...
By JasonH Nov 13, 2024