Created
November 30, 2019 03:07
-
-
Save rileyrichter/062dd6072223f6a4f831b5aba4e22962 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?