Ivanna Von Rodt Ivanna Von Rodt - 4 months ago 13x
HTML Question

How to use a random HTML file in JavaScript?

I'm having problems trying to figure this out, specifically because I'm really new to javascript. So, I have this place in my page where I want to have a random html file that I will make in html and I will like to link to it. I want it to be randomized every time the page refreshes, because I will do lots of these html files.

So, is this possible? I've searched for answers but all of the randomized html questions I've found are about the whole page. I just want a little part of the page to be randomized, similar to the random image I have in the same webpage.

The page I'm using for testing is this one: http://vannapruebas.jcink.net/ , I would like to use the toggle that says "búsquedas" for this. So, any help? thanks and exuse my poor english!


All you have to do is make a list of all your css, then you pick one randomly with -> Getting random value from an array

var listOfCSS = ["sample/your.css","sample/another.css"];
var css = listOfCSS[Math.floor(Math.random()*listOfCSS.length)];
<link id="myChangingCSS" href="sample/default.css" rel="stylesheet">