On Click go to Random Url RRS feed

  • Question

  • In my website navigation, rather than going to a specified url upon clicking a link, I would like the user to be directed to a random page in my site selected from a defined list of pages. Is there an easy way to do this using Expressions? 

    I've seen some solutions that use javascript with a list of urls embedded in the script, but to allow for ease of updating, I would prefer to have a list in a txt file or something like that. 

    Could you please help, this has been wrecking my head and is one of my last stumbling blocks!!


    • Moved by Eric Juteau Sunday, April 25, 2010 3:02 PM Not an Encoder question. (From:Expression Encoder)
    Sunday, April 25, 2010 1:34 AM

All replies

  • You're going to have to use something that has the ability to randomize a list and then select from that list, and HTML does not. (Actually, it's more like randomizing a single index value pointer into an array, but you get the idea.) For your purposes, that means javascript. No non-dynamic technology will do the job for you.

    Frankly, I don't see the problem. Javascript files are nothing but text files with a js extension, so modifying the list of URLs is no different in a js file than in a text file.


    C'mon, folks. This isn't rocket science, nor neurosurgery. It's "Expression" (singular) "Web" (singular), in that order, followed by a version numeral if you wish to be specific. It is often abbreviated "EW." It is not "Web Expression," "Expressions Web," "Web Expressions," or plain "Expression" or "Expressions." Not using the correct name indicates either ignorance or laziness. Most folks would rather avoid the appearance of either.
    • Proposed as answer by Time Bandit Sunday, April 25, 2010 3:48 PM
    Sunday, April 25, 2010 3:41 PM