Variable number of tabs based on referring URL

silversorensen
New Member
4 0 0

I am trying to create a page that will have a variable number of tabs depending on the query string of the referring URL.

I've been able to get the referring URL by inserting this script:


<script language="javascript">
var ref=document.referrer;
document.write(ref)
</script>

How can I make it so that IF ref contains "this-text" then load 2 tabs?

Or, for that matter, to keep tabs out of the equation: IF ref contains "this-text" then <p>This works!!</p>

Any input will be greatly appreciated.

Thank you,

-silver

0 Likes
PaulNewton
Shopify Partner
2799 160 518

use indexOf

https://stackoverflow.com/questions/3480771/how-do-i-check-if-string-contains-substring 

https://stackoverflow.com/questions/1789945/how-to-check-whether-a-string-contains-a-substring-in-ja...

 

Note: Liquid templates do not have user definable URL parameters so parameter parsing needs to be done on the frontend in javascript

Problem Solved? ✔️Accept and ? Like the solution so you can help others.
Buy me a coffee ☕ paypal.me/paulnewton or donate to eff.org
Confused? Busy? Buy a custom solution paull.newton+shopifyforum@gmail.com
0 Likes

You want to create if/else and display 2 tabs with Liquid code?
This is not possible, you cannot create or declare a Liquid variable for JS.
Hope it helps!

LitExtension - #1 Shopping Cart Migration Expert
If our answer is helpful then please accept as solution!
Are you looking for a solution to migrate to Shopify? Contact us for further assistance.
Try our FREE DEMO now!
0 Likes