Forum Moderators: open

Message Too Old, No Replies

Selected language using Javascript

         

toplisek

12:03 pm on May 25, 2016 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have selection like:

<select name='lng' class='language-select'>
<option value='en-US'>English</option>
<option value='fr-FR'>French</option>
<option value='de-DE'>Spanish</option>
</select>


Currenty it is detected language with link like:
<a href="http://www.example.com/?DefineLang=fr-FR">French</a>
It will be retrieved variable using GET method but search engines will detect URL like
http://www.example.com/index.php?DefineLang=fr-FR
This is not search engine friendly.

language-select variable should be detect as en-GB, fr-FR.
Example: $(document).ready(function()
{
$('select.language-select').on('change', function(evt)
{
}
);
}
);

How to do it in the correct way using languages as select option and also as link:
<a href="http://www.example.com/de-DE/heim>Deutsch</a>

[edited by: bill at 10:10 pm (utc) on May 29, 2016]
[edit reason] Use example.com instead [/edit]

Chico_Loco

7:20 am on May 29, 2016 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am not certain I understand the question, but... would using something like an HTML list with hyperlinks (<li>'s instead of a <select>) styled to be a drop-down type of navigation solve your problem?

Or is the question about how to avoid any of the URL's with query strings from getting indexed?

toplisek

8:06 am on May 31, 2016 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Sorry if I was not clear.
Webstes do not use GET method to be redirected to another language. In this way it is seen ?DefineLang=fr-FR.
Is there Javascript code to avoid ?DefineLang=fr-FR but DefineLang variable and its value will be detected as value?

robzilla

10:55 am on May 31, 2016 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



To avoid GET you could store the language preference in the session data or a separate cookie.

However, I would also favor Chico_Loco's approach of a list-style drop-down rather than a <select> form.