Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Sep 2008
    Posts
    67
    Thanks
    8
    Thanked 2 Times in 2 Posts

    switching scripts

    Hi,

    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 ?

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    Hard to answer without seeing any code, but surely something like

    Code:
    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)

  • #3
    New Coder
    Join Date
    Sep 2008
    Posts
    67
    Thanks
    8
    Thanked 2 Times in 2 Posts
    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
    which, when you get to the link "another question?", leads to a different page.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •