Skip to content

Instantly share code, notes, and snippets.

@rileyrichter
Created November 30, 2019 03:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rileyrichter/062dd6072223f6a4f831b5aba4e22962 to your computer and use it in GitHub Desktop.
Save rileyrichter/062dd6072223f6a4f831b5aba4e22962 to your computer and use it in GitHub Desktop.
<script>
var links = [
"quote-1",
"quote-2",
"quote-3",
"quote-4",
"quote-5",
"quote-6",
"quote-7",
"quote-8",
"quote-9",
"quote-10",
"quote-11",
"quote-12",
"quote-13",
"quote-14",
"quote-15",
"quote-16",
"quote-17",
"quote-18",
"quote-19",
"quote-20"
]
function openSite() {
// get a random number between 0 and the number of links
var randIdx = Math.random() * links.length;
// round it, so it can be used as array index
randIdx = parseInt(randIdx, 10);
// construct the link to be opened
var link = 'https://random-quote-generator.webflow.io/quote/' + links[randIdx];
// Open the link
window.location.assign(link);
};
</script>
@darusim-zz
Copy link

Hi @rileyrichter, what if there are more than 100 cms items, and new items will be added daily? Are there better ways to handle the links rather than copy-and-paste them 1 by 1?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment