Solved - In Forum - Code not working to show/hide elements

…since the Forum homepage looks a bit dull, I’m trying to add text-elements but that should only appear when on the forum homepage. I thought this would work but in LIVE it doesn’t. I can’t console.log the LIVE page so it’s hard to see why they don’t match…

import wixLocation from ‘wix-location’;
$w.onReady(function () {
let url = wixLocation.url;
url = url.toString();
//console.log(url)
if( url === “https://www.emunations.com/forum/”) {
$w(“#textg0”).show();
}
else
$w(“#textg0”).hide();
});

Should my URL/HREF be indicated differently or is there a better approach to this?
Thanks!

Still unresolved; any references would also be appreciated :stuck_out_tongue:

You can use the browser’s console in order to see console.log() messages when running your Live site.

Great! It’s working :slight_smile:

A little too well😅 Turns out the url doesn’t change (in browser console) if I click to see a thread/post so the text never redisappears.

I will continue investigating a workaround

You would need to edit your location code and combine it with onChange.

This way it will read something like: OnReady get current URL if it equals something then do something. OnChange get current URL if it equals something then do something.

https://www.wix.com/corvid/reference/wix-location/onchange

That resolved it, thanks :slight_smile: