0

I am coding to change language by using Read with Korea Language

Example:

Currently URL is:

http://www.domain.com/EN/index.php

When user press onClick URL change to:

http://www.domain.com/KO/index.php

I mean that I just want to replace EN to KO then reload page again.

Appreciate for your help.

2
  • Wow... You should definitely use jQuery on this one. Commented May 30, 2012 at 4:53
  • 1
    Is there any reason not to use a just a link? This doesn't really sound like it needs javascript Commented May 30, 2012 at 5:06

3 Answers 3

5

If you reload the page, why not just use normal a href.

<a href="http://www.domain.com/KO/index.php">KO</a>
Sign up to request clarification or add additional context in comments.

1 Comment

<a href="javascript:window.location.href.replace('/EN/', '/KO/')" >KO</a> or unobtrusively
1

Use the window.location object to get to the new URL:

window.location = window.location.protocol + "//" 
    + window.location.host + window.location.pathname.replace("EN", "KO");

Or I guess simpler, just:

window.location = window.location.href.replace("/EN/", "/KO/");

Comments

0

If you want to load region specific URL check IP filtering for geological locations. Depending upon IP you'll get, load corresponding URL. e.g. You can use :

 if(ip address coming from <region>)
  window.location.replace("http://www.domain.com/<region>/index.php");

Comments

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.