I was just thinking about a script (the recent slideshow posted in the submitted section), and trying to think about a solution to allow, without a lot of recoding, for the script to have multiple instances.
This is very true of many scripts; users want more than one, and doing so would cause problems due to variable names and such.
So, the idea that we all know about is renaming the variables and names/id's of the elements.
However, this is something of a pain.
Is it possible for javascript to generate javascript?
One could simply make the entire script a string within a host script, then change the variable names upon each creation.
Short of this, the solution I could see if PHP in that the javascript would, upon each request for an instance of the script, call the javascript at "myscript.php" (as an external .js file), using a get variable to specific a prefix (or suffix) to the variables, allowing multiple instances.
Basically, the idea is an instance generator. This could be a very helpful improvement to many scripts and an easy way to solve the frequent questions regarding this issue. It would also allow for no specific recoding of the scripts, but just a quick analysis as to which variables etc should be altered to allow for multiple versions, then that could be built into a standard javascript (or if need be PHP) framework to generate these.
Thoughts?



Reply With Quote


Bookmarks