vchris Posted April 1, 2007 Share Posted April 1, 2007 I need to get the language from a file. My files are named bla_e.php and bla_f.php. How can I identify the language in javascript? Link to comment Share on other sites More sharing options...
vchris Posted April 2, 2007 Author Share Posted April 2, 2007 Or do you know how to get only the filename? Link to comment Share on other sites More sharing options...
aspnetguy Posted April 2, 2007 Share Posted April 2, 2007 var url = window.location;var lang = "";if(url.indexOf("_e.php") != -1) lang = "english";else if(url.indexOf("_f.php") != -1) lang = "french";else lang = "unknown"; Link to comment Share on other sites More sharing options...
vchris Posted April 3, 2007 Author Share Posted April 3, 2007 Thanks!Always wondered are the { and } optional in javascript? Link to comment Share on other sites More sharing options...
aspnetguy Posted April 3, 2007 Share Posted April 3, 2007 only if you have 1 line followinglike if(condition) dosomething();//orif(condition) dosomething();//unexpected resultif(condition) doSomething(); do somethingElse();//what the above is really doingif(condition){ dosomething();}dosomethingElse(); Link to comment Share on other sites More sharing options...
vchris Posted April 6, 2007 Author Share Posted April 6, 2007 var url = window.location;var lang = "";if(url.indexOf("_e.php") != -1) lang = "english";else if(url.indexOf("_f.php") != -1) lang = "french";else lang = "unknown"; I tried your code but I get javascript errors. It says that url.indexOf is not a function. Then I tried url.search and it said the same thing... Link to comment Share on other sites More sharing options...
Bassam122 Posted April 9, 2007 Share Posted April 9, 2007 I tried your code but I get javascript errors. It says that url.indexOf is not a function. Then I tried url.search and it said the same thing...hi,first try to assign the var url the value window.location.href(var url = window.location.href) then try the codew again. Link to comment Share on other sites More sharing options...
vchris Posted April 10, 2007 Author Share Posted April 10, 2007 Works perfect! thanks! Link to comment Share on other sites More sharing options...
aspnetguy Posted April 10, 2007 Share Posted April 10, 2007 Thanks for catching that. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now