View Full Version : switching scripts

06-20-2010, 03:18 AM

I have two versions of a script: version A gets used on a visitor's first round, where the page is dynamically altered; if the visitor wants to do another round, I need to switch to version B.

I could load both versions initially, but that seems overkill. Any suggestions ?

Philip M
06-20-2010, 10:15 AM
Hard to answer without seeing any code, but surely something like

var round = 0;

if (round == 0) {
... do something
round ++;
else {
... do something else

would work?

"Seize the day, put no trust in the morrow!" [Carpe diem, quam minimum credula postero.] -Horace - Roman lyric poet & satirist (65 BC - 8 BC)

06-21-2010, 08:40 AM
Going with your suggestion, "so something" and "do something else" would be switching <script> tags... can that be done with 'document.write' ?

Currently, I'm using a stopgap method of having a link which says "another question?", ("round") which redirects to a new page to which version B of the script is linked.

What this does is to avoid the pitfalls of setting the altered page back to its original state (still working on this, not as simple as it looks), hiding some initial content-- instructions which the viewer no longer needs--and then linking in a new script which appears to behave like the first, but does slightly different things.

Have a look here (http://www-personal.usyd.edu.au/~ctillam/Changes/basic.htm)
which, when you get to the link "another question?", leads to a different page.