How do you create a link that will take you to a random page in your website?

  • 2
  • Question
  • Updated 6 years ago
  • Answered
I'm making a games website and I want a link/button that can take you to a random page on my website. Since Yola doesn't grant access to the head section, is there a way for me to do this?
Photo of Daniel Lowe

Daniel Lowe

  • 1 Post
  • 0 Reply Likes
  • frustrated

Posted 6 years ago

  • 2
Photo of Laura Thomas

Laura Thomas, Social Media Coordinator

  • 4536 Posts
  • 211 Reply Likes
Hi Daniel,

You do not need access to the head section to create your own buttons.You will need to create the button in a photo editor, save it as an image, and then link it to the page, website, file or email address you would like it to go to just as you would create an image link.

Add the button to your page, using the Picture Widget.
Click on the "Edit" link on the top left-hand corner of the Picture Widget.
Click on "Choose A Link" and make your selection; you will be able to choose to link to a page in your site, an outside URL, an email address or a file.
Click on "Save".
To check that your link is working, preview your page and then click on the link.
Photo of Philip Taylor

Philip Taylor

  • 355 Posts
  • 66 Reply Likes
The script below will transfer randomly to any page listed in it, if you change the howMany number to the highest listed page (in this case, 9) which will be one less than the number of pages. Take out the <!-- at the top and --> at the bottom. Place it on its own page in an HTML widget.

CAUTION: Before you run it, save it to a different page with the <!-- and --> as they are now, otherwise you won't be able to get back to the page it's on to edit it later. To edit it go to Page Manager and delete the page and re-name the backup you made to this page's name.
<!--
<SCRIPT LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://www.javascriptsource.com -->

<!-- Begin
var howMany = 9; // max number of items listed below
var page = new Array(howMany+1);

page[0]="first.php";
page[1]="second.php";
page[2]="third.php";
page[3]="fourth.php";
page[4]="fifth.php";
page[5]="sixth.php";
page[6]="seventh.php";
page[7]="eighth.php";
page[8]="ninth.php";
page[9]="tenth.php";

function rndnumber(){
var randscript = -1;
while (randscript < 0 || randscript > howMany || isNaN(randscript)){
randscript = parseInt(Math.random()*(howMany+1));
}
return randscript;
}
quo = rndnumber();
quox = page[quo];
window.location=(quox);
// End -->

-->