stochastic hyperlink required
March 25, 2009 12:47 PM   Subscribe

Question about linking pages in a slightly random way with Dreamweaver...

I have a basic understanding of html and can make my way around dreamweaver (which I learned by myself, so I am definitely not an advanced user!), but for a multimedia project I'm working on, I'd like to create a specific type of link. I would like to create a hyperlink that points to a group of pages (that would be grouped in a folder, or perhaps there is a tagging system that could be put into place?), but that randomly picks one of these pages (not the one that's currently live). I'm not sure if this is feasible with my poor programing knowledge, but I would hope there's a straightforward way to achieve it!

My idea is that if the audience enjoy a text (or an image for that matter), they could click on it and be directed to another related page, but not in a linear or predictive way.

Additionnal infos: the project is for an installation, so everything is going to be local (ie on the computer that runs the installation, in safari with mega zoomer). I can use good old dreamweaver 8 and/or flash mx to complete this simple task. I thought for a while that a cms might be easier to deal with to achieve that effect, but I already have a lot of pages already created and know nothing about css.
posted by ddaavviidd to Computers & Internet (1 answer total)
Best answer: You'd use JavaScript for this. If you name all the pages like page_1.html, page_2.html, etc., then you would generate a random number in the range that you have and have the link forward you to page_x.html. Something like:

function randomPage() {
var r = Math.floor(Math.random() * 10) + 1;
window.location = "page_" + r + ".html";

And make it the onclick for your link.
posted by disaster77 at 12:56 PM on March 25, 2009

« Older Two players, one iPhone. What games are good?   |   University of Salamanca Housing Newer »
This thread is closed to new comments.