Multilingual websites and questions about changing the language to refresh the page

Source: Internet
Author: User
For multilingual websites, the problem of changing the language refresh page is that after selecting a language, you need to refresh all the subtopics under the topic. I used select & nbsp; onchanage & nbsp; the event code is as follows: & lt; script & gt; function & nbsp; chan multi-language website. if you change the language, refresh the page.



First Watch

The problem is that after you select a language, you need to refresh all the subtopics under the topic.

I used the select onchanage event

The code is as follows:


Script
Function changeLan ()
{
Var selectVal = document. topForm. select1.options [document. topForm. select1.selectedIndex]. value;
// Alert (selectVal );

Window. location. href = "change_language.php? Lan = "+ selectVal;
Window. parent. location. reload ();

}
 
Script

The change_language.php page code is very simple, just to save the session

The code is as follows:

Session_start ();
$ Lan = $ _ REQUEST ['Lan '];
// Echo $ lan;

$ _ SESSION ["lan"] = $ lan;

?>


The problem is:
After refreshing the upper-level page, the session value does not exist.
What is the reason?
Please kindly advise, novice!



------ Solution --------------------
Set window. parent. location. reload ();
Put it in change_language.php.

Possible cause:
Window. location. href = "change_language.php? Lan = "+ selectVal;
The current framework page is refreshed, but it does not wait for the page to return. If you wait for the response, the next sentence will be invalid.
Window. parent. location. reload ();
Refresh the entire framework. It can be considered that this sentence is executed in parallel with the previous sentence. When the page is executed, the processing of the previous sentence may not be completed

Do you use session for every page?


------ Solution --------------------
Reference:
Set window. parent. location. reload ();
Put it in change_language.php.

Possible cause:
Window. location. href = "change_language.php? Lan = "+ selectVal;
The current framework page is refreshed, but it does not wait for the page to return. If you wait for the response, the next sentence will be invalid.
Wind ......


Indeed, these two JavaScript statements conflict. you can write the header ("location: index. php") in change_language.php ");

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.