Variable number of tabs based on referring URL

silversorensen
Tourist
6 0 8

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

Replies 2 (2)

PaulNewton
Shopify Partner
6275 574 1324

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

Save time & money ,Ask Questions The Smart Way


Confused? Busy? Get the solution you need paull.newton+shopifyforum@gmail.com


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Buy Paul a Coffee for more answers or donate to eff.org


LitExtension
Shopify Partner
4860 1001 1135

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 - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify