Hello all.
I wrote small script, which check GET method values from URL and load content of proper file info div.
- function loadContent(content, language) //LOAD CONTENT INTO DIV (i.e. ordo_en.txt)
- {
- $('#content').load(content + '_' + language + '.txt', function() {
- alert(cont + '_' + lang + '.txt'); // alert as 'debbuger' info
- });
- }
- function urlGet(name){ //GET VALUES FROM URL
- var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
- return results[1] || 0; // if GET exist return value, if not - return 0;
- }
- $(document).ready(function(){
- var lang = "en"; //set default language to english
- var page = "ordo"; //set default page to ordo
- if(urlGet('p') !== 0){ //if GET method p (page) is not null
- page = urlGet('p'); // set page var to GET value
- alert (page); // for debbuging
- }
- if(urlGet('l') !== 0){ // similary as upper
- lang = urlGet('l');
- alert (lang);
- }
- loadContent(page,lang);
- });
Main problem is, the script doesen't work when url hasn't GET method values.
The second problem is, that when language = pl (index.html?p=ordo&l=pl) script shows that l = 0 (with other values for 'l' like gr, en, de script works well).
What's wrong?
Thank you for response in advance.