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