Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<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

This comment has been minimized.

Copy link

@darusim darusim commented Apr 25, 2020

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
You can’t perform that action at this time.