Streaming live at 10am (PST)

Help on Javascript for Lang Switcher's link

Hi, I am doing a website on Webflow, but need to implement a special off-site translation service, and need some help on javascript.

I need to make a language switch and make it able to go to the respective translated page. The link of that switch is given an id “ext-trans”:

<a id="ext-trans" href="#" > LINK </a>

Is there a way to detect the current browser’s URL, such as:

and then use a javascript to replace href=“#” with this pattern:
( no matter the current URL is /en/ or /tc/ or /sc/, just need /tc/ in result )
( xxxxx is the remaining path )

I tried to write a javascript to handle this, but it looks like something’s wrong and it does not work…

  $('#ext-trans').attr('href', '' + window.location.hostname + '/tc' +  window.location.pathname.substr(3))

It would be so great if anyone would know how to do it. :raised_hands:t2:

Thanks a lot in advance!


( The Website | Read-only link )

Anyone here good at JavaScript could help?