•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 391,873 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,384 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 9355 | Replies: 2
![]() |
•
•
Join Date: Apr 2006
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
Dear All,
In my "Javascripts\english" folder I have language related javascript files. In one of these files there is a function I want it to get the return value of a function getChangedDate() from a general Javascript file called changes.js in my "Javascripts" folder.
I also want to use the same getChangedDate() function in from my "Javascripts\français", "Javascripts\italiano", "Javascripts\deutsch", "Javascripts\nederlands", ... folders.
How can I get this return value?
Someone suggested this soluton:
I also tried
or
or
Non of these work, probably because there is not such a thing as a standard load() function.
In my "Javascripts\english" folder I have language related javascript files. In one of these files there is a function I want it to get the return value of a function getChangedDate() from a general Javascript file called changes.js in my "Javascripts" folder.
I also want to use the same getChangedDate() function in from my "Javascripts\français", "Javascripts\italiano", "Javascripts\deutsch", "Javascripts\nederlands", ... folders.
How can I get this return value?
Someone suggested this soluton:
load("../changes.js") ;
changedDate = getChangedDate() ;
I also tried
load("/Javascripts/changes.js") ;
changedDate = getChangedDate() ;
or
load("\Javascripts\changes.js") ;
changedDate = getChangedDate() ;
or
load("..\changes.js") ;
changedDate = getChangedDate() ;
Non of these work, probably because there is not such a thing as a standard load() function.
•
•
Join Date: May 2005
Location: Wellington, New Zealand
Posts: 182
Reputation:
Rep Power: 4
Solved Threads: 3
There are several things you can do... for example it is possible to dynamically add and remove html nodes from your page using javascript. But I find this isn't particularly quick (sometimes you need to wait before you try and call a newly loaded script - using setTimeout or similar).
But I think there are a couple of simple solutions to your problem - either using some kind of server side technology to decide on language and draw the page to fit... or write a global interface to your language files. So you only have one function getChangedDate() , but this calls a specific getChangedDate() based on a global variable.. i.e.
function getChangedDate() { changedDate = (language == english)?getEnglishChangedDate():getFrenchChangedDate() ; }
Another solution I'd like is to use JavaScript Classes. This would give you the ability to keep the method naming, but you'd still need some logic...
function getChangedDate() { changedDate = (language == english)?English.getChangedDate():French.getChangedDate() ; }
I'd say the best practise would be to use a server side based solution, unless this is not available to you.
But I think there are a couple of simple solutions to your problem - either using some kind of server side technology to decide on language and draw the page to fit... or write a global interface to your language files. So you only have one function getChangedDate() , but this calls a specific getChangedDate() based on a global variable.. i.e.
function getChangedDate() { changedDate = (language == english)?getEnglishChangedDate():getFrenchChangedDate() ; }
Another solution I'd like is to use JavaScript Classes. This would give you the ability to keep the method naming, but you'd still need some logic...
function getChangedDate() { changedDate = (language == english)?English.getChangedDate():French.getChangedDate() ; }
I'd say the best practise would be to use a server side based solution, unless this is not available to you.
•
•
Join Date: Apr 2006
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
•
•
Originally Posted by alpha_foobar
There are several things you can do... for example it is possible to dynamically add and remove html nodes from your page using javascript. But I find this isn't particularly quick (sometimes you need to wait before you try and call a newly loaded script - using setTimeout or similar).
But I think there are a couple of simple solutions to your problem - either using some kind of server side technology to decide on language and draw the page to fit... or write a global interface to your language files. So you only have one function getChangedDate() , but this calls a specific getChangedDate() based on a global variable.. i.e.
function getChangedDate() { changedDate = (language == english)?getEnglishChangedDate():getFrenchChangedDate() ; }
Another solution I'd like is to use JavaScript Classes. This would give you the ability to keep the method naming, but you'd still need some logic...
function getChangedDate() { changedDate = (language == english)?English.getChangedDate():French.getChangedDate() ; }
I'd say the best practise would be to use a server side based solution, unless this is not available to you.
It's worth studying your suggestion
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
- How to call a PHP function from Javascript and return the results back into Javascrip (PHP)
- Call to undefined function mysql_connect() (PHP)
- Function call problem (HTML and CSS)
- using OCI to call a ORACLE stored function (C++)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: How to enable or disable Internet Explorer tool bar buttons using javascript
- Next Thread: Error reading XML file in Javascript


Linear Mode