0

how would one take part of the current page's url and change just a couple letters of it? Assuming jQuery would be the way to go?

for instance: clicking a button counts the number of gets the 19th and 20th character EN of

www.papercuts.com/EN/boxes/mailingtubes.html

and changes it to DE

www.papercuts.com/DE/boxes/mailingtubes.html

2 Answers 2

2

and redirects?

window.location = window.location.href.replace(/.com\/.{2}/, '.com/DE');

edit: all language support by anstosa

Sign up to request clarification or add additional context in comments.

1 Comment

This will work regardless of what the current language currently is: window.location = window.location.href.replace(/.com\/.{2}/, '.com/DE');
0
germanURL = englishURL.replace(/papercuts.com\/EN\//, 'papercuts.com/DE/');

Simply use replace to replace the papercuts.com/EN/.

2 Comments

this doesnt account for pages not using www.
@Chad I though this would be self explainable, but I'll edit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.