Site logo

Archived topic

Display element only while url contain keywords

2 replies · Started by Marcin on November 13, 2020

Viewing posts 1–3 of 3

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:

Holder
<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!

This archived topic is closed to new replies.