I have a problem with my javascript which doesn't work properly on certain browsers, to be accurate Firefox and Google Chrome (tested with IE7, IE8, Opera[latest version], Firefox[latest version] and Google Chrome[latest version]).
The code
What is it meant to be doing? It should navigate to a different url depends on the parameter passed to the function (and after passing some checks). More practically it changes the language on the website. I've used it with images of the flags using onClick event. It does work on Opera and IE but it doesn't work on Firefox and Google Chrome (nothing happens when I press a flag).Code:function changeLanguage(lang) { var url = window.location.href; var filename = url.substring(url.lastIndexOf('/')+1); var pathname = url.substring(0, url.lastIndexOf('/')+1); if (lang == 'en' && url.indexOf("en/") == '-1') { window.navigate(pathname +"en/"+ filename); } if (lang == 'pl' && url.lastIndexOf("en/") != '-1') { var pathname = url.substring(0, url.lastIndexOf('/')-2); window.navigate(pathname + filename); } }
Any ideas?



Reply With Quote

Bookmarks