How redirect the url main domain to subdomain using javascript

I developing one website like In mysite i list out city list then while click the city its goes to subdomain like so how to achieve this using javascript. so share your ideas and suggestions.

Sounds like you don’t need JS. Just click it and go to the site. If you need different then you will have to explain it that way.

Thanks for reply. I am developing one classifieds site so i want know structure like, while click location it goes to subdomain( and display contents regarding subdomain. so i created subdomain for all cities and redirect to i am in struggle in landing page of after loading subdomain url because it shown individual page for each subdomain. share your ideas and suggestion.

I’m sorry. Tried as I might. I couldn’t understand the question again.