Archived topic
Display element only while url contain keywords
2 replies · Started by Marcin on November 13, 2020
Hello, I have a problem with my page. I'm using 3-rd party searching tool, so I have only one page in my shop which i like. However while someone search for category I want to display more information about it. My searching tool adds slug to URL for example "_cat_category1" and it is the only diffrent between categories.
I want to add div with difrent conntent depending of this slug. I've tried using JS like that:
<script>
displayContent();
function displayContent(){
var d = document.getElementById("catContent");
if(window.location.href.include('_cat_category1'))
d.innerHTML = window.location.href;
}
</script>
But it does not work. Could You help me?
Sorry for disturbing, changing include to match works
Hi there,
glad to hear you found a solution!