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
2 Answers 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
Ansel Santosa
This will work regardless of what the current language currently is:
window.location = window.location.href.replace(/.com\/.{2}/, '.com/DE');
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
lang-js