random page choice from a link

How may i direct from a link randomly to a choice of internal pages within freeway pro web site

Thanks

Patrick


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

No Actions for this, but you could write a little JavaScript to do this. I would put all of the URLs into an array, and then use Math.random to make a number between 0 and length of that array -1. Get a plain-text editor, and make a list of all the URLs you want to be in the running for random loading. Then change that list into an array:

foo.html
bar.html
baz.html

becomes

var links = [‘foo.html’, ‘bar.html’, ‘baz.html’];

Now, to pick one at random, you need a number that is either 0, 1, or 2 (the first element of an array is always indexed 0, and increments up from there).

var random = Math.floor(Math.random() * 3);

Put those together in a function that listens for a click on your link:

var random_link = function(evt){
  evt.preventDefault();
  window.location.href = links[random];
};

So if you have the previous 3 statements in a tag in the head of your page, then extend your link (using the Extended interface in the Hyperlink palette) with the following:

  • Name: onclick
  • Value: return random_link()

And now when you click on that link, you will get one of the random links in its place.

Walter

On Nov 3, 2014, at 7:02 PM, Patrick Mimran email@hidden wrote:

How may i direct from a link randomly to a choice of internal pages within freeway pro web site

Thanks

Patrick


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Hi Patrick,
Walter’s suggestion of using JavaScript will work perfectly well for you although I’d probably do this in PHP personally. The benefit would be that you wouldn’t need to update the code if the pool of available pages changed.

The idea is that you’d have a simple PHP page that picks another page at random (possibly from a given directory of files) and passes the user along to that page automatically. You’d then link to the PHP page as if it were a regular page.

If you’d like help with the PHP then feel free to get back in touch.
Regards,
Tim.

On 4 Nov 2014, at 00:02, Patrick Mimran wrote:

How may i direct from a link randomly to a choice of internal pages within freeway pro web site


Experienced Freeway designer for hire - http://www.freewayactions.com


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options