im using a paid plan and i would like to use the randomized effect on my page. I’ve been using this as a reference but the issue im facing is that i don’t want to have a random button for the whole website. i only want it for 4-5 pages. is there a way to code this somehow? i know the bare basics of coding but im not an expert but i would love to make this work!
Hey,
the easiest way would be something like this:
setTimeout(function() {
let links = [];
links[0] = "http://www.google.com/";
links[1] = "http://www.bing.com/";
links[2] = "http://www.yahoo.com/";
links[3] = "http://www.apple.com/";
function openLink() {
var i = ~~(Math.random() * links.length);
window.location.href = links[i];
return false;
}
$('[data-id=insert-your-data-id]').on('click', function() {
openLink();
});
}, 1000);
make sure to paste the data-id of your randomizebutton.
hey, thanks so much! <3 so if the links that i wanted to randomize is within my website (within the readymag pages) then how would i add the links for that?
just paste in the urls of your rm project
Hi, I’m using your code as well and have not been able to get it to work, I have put in my pages, inserted the ID of the button widget I used, but when I try to click the button it does nothing. Am I missing something completely obvious?
did you put the code in script brackets?
< script >
… code…
< /script >
(erase the blank characters)
That works, thank you! <3 When I now press the button once and navigate back to the main site and try to press the button again, it doesn’t work. How do I edit the timeout for it to work over and over again without having to reload the entire site?
well here the button works again if I go back and click again.
have you tried different browsers?