# \[Pro\] Random Link Generator in Freeway

**URL:** <https://discourse.softpress.com/t/pro-random-link-generator-in-freeway/11474>\
**Category:** Freeway\
**Created:** [July 24, 2011, 9:49am UTC](https://discourse.softpress.com/t/pro-random-link-generator-in-freeway/11474 "2011-07-24T09:49:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Coldereo](https://discourse.softpress.com/letter_avatar_proxy/v4/letter/m/49beb7/32.png) [@Michael\_Coldereo](https://discourse.softpress.com/u/Michael_Coldereo)\
**Post date:** [July 24, 2011, 9:49am UTC](https://discourse.softpress.com/t/pro-random-link-generator-in-freeway/11474/1 "2011-07-24T09:49:53Z")

</div>

Hi everyone

I am thinking of something challenging with FW. Is it possible to create a Random Link Generator in Freeway?

For example, I have 20 external links, which I would like to be drawn randomly and opened in a new window, when someone clicks on a button. I am not sure how do I go about this.

any suggestions?

* * *

freewaytalk mailing list  
email@hidden  
Update your subscriptions at:  
[http://freewaytalk.net/person/options](http://freewaytalk.net/person/options)

---

<div class="post-metadata">

**Author:** ![waltd](https://discourse.softpress.com/user_avatar/discourse.softpress.com/waltd/32/2720_2.png) [@waltd](https://discourse.softpress.com/u/waltd)\
**Post date:** [July 24, 2011, 11:30am UTC](https://discourse.softpress.com/t/pro-random-link-generator-in-freeway/11474/2 "2011-07-24T11:30:04Z")

</div>

The simplest way to do this is with JavaScript. Put all the possible link targets in a structure like an array, then roll the dice at the moment that the button is pressed and use one of them.

The only down-sides to this are that the links are all exposed in the source of your page, and modifying the list of links requires delving into the Page / HTML Markup dialog. As long as neither of those is a show-stopper, I can dig out the code for you.

If you need to obscure where the link goes, or if you need to give your client a nice control panel to change the links, then you’ll need to use a server-side language to do this. Again, your needs drive this decision, so a little more info would be helpful.

Walter

* * *

freewaytalk mailing list  
email@hidden  
Update your subscriptions at:  
[http://freewaytalk.net/person/options](http://freewaytalk.net/person/options)

---

<div class="post-metadata">

**Author:** ![waltd](https://discourse.softpress.com/user_avatar/discourse.softpress.com/waltd/32/2720_2.png) [@waltd](https://discourse.softpress.com/u/waltd)\
**Post date:** [July 24, 2011, 3:28pm UTC](https://discourse.softpress.com/t/pro-random-link-generator-in-freeway/11474/3 "2011-07-24T15:28:53Z")

</div>

Here’s an example of that JavaScript random link:

> <https://gist.github.com/walterdavis/1102724>

If you want to use this, simply apply the Protaculous Action to your  
page, set the Library picker to prototype-packed, and click on the top  
Function Body button and paste in this code. You will need to modify  
the following variables: where I have the word myButton, you need to  
substitute with the ID of your actual button (or rename your button to  
match using the TItle field in the Inspector. Where I have  
page\_one.html etc., change those to be the actual filenames of your  
target pages. If you want these to be external (not relative) URLs,  
then you must make those fully-qualified URLs, with http:// and the  
full domain and URL.

Walter

On Jul 24, 2011, at 7:30 AM, waltd wrote:

> The simplest way to do this is with JavaScript. Put all the possible  
> link targets in a structure like an array, then roll the dice at the  
> moment that the button is pressed and use one of them.

* * *

freewaytalk mailing list  
email@hidden  
Update your subscriptions at:  
[http://freewaytalk.net/person/options](http://freewaytalk.net/person/options)

---

<div class="post-metadata">

**Author:** ![Michael\_Coldereo](https://discourse.softpress.com/letter_avatar_proxy/v4/letter/m/49beb7/32.png) [@Michael\_Coldereo](https://discourse.softpress.com/u/Michael_Coldereo)\
**Post date:** [July 25, 2011, 11:05am UTC](https://discourse.softpress.com/t/pro-random-link-generator-in-freeway/11474/4 "2011-07-25T11:05:23Z")

</div>

Thanks waltd, great info!

* * *

freewaytalk mailing list  
email@hidden  
Update your subscriptions at:  
[http://freewaytalk.net/person/options](http://freewaytalk.net/person/options)
