user1425141
user1425141

Reputation: 5

add path into Current URL Location

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.

Upvotes: 0

Views: 3494

Answers (3)

iDaemon
iDaemon

Reputation: 363

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");

Upvotes: 0

McGarnagle
McGarnagle

Reputation: 102753

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/");

Upvotes: 1

xdazz
xdazz

Reputation: 160843

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

<a href="http://www.domain.com/KO/index.php">KO</a>

Upvotes: 5

Related Questions