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
TimWolla
32.8k8 gold badges67 silver badges97 bronze badges
asked Jan 23, 2012 at 21:07

2 Answers 2

2

and redirects?

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

edit: all language support by anstosa

answered Jan 23, 2012 at 21:11

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/.

answered Jan 23, 2012 at 21:10

2 Comments

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

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.