2
I have a code in which he creates me a page as if it were a theme, picking randomly the css classes, but what he does is create the "theme" within the page that this button, and would like it opened up a new page with the selected theme.
Follow the code js
Code that generates the classes
var classesRM = ['fundoRomantico', 'fundoRomantico1', 'fundoRomantico2'];
var classestopoRmt = ['topo-romantico', 'topo-romantico1', 'topo-romantico2'];
var classesmenuRmt = ['romantico-menu-01', 'romantico-menu-02', 'romantico-menu-03'];
var classesfootRmt = ['footer-romantico', 'footer-romantico1', 'footer-romantico2'];
var classesFontTexto = ['font-romantico', 'font-romantico1', 'font-classica', 'font-classica1', 'font-moderno', 'font-moderno1'];
var classesFontTitulo = ['font-titulo-romantico', 'font-titulo-romantico1', 'font-titulo-classica', 'font-titulo-classica1', 'font-titulo-moderno', 'font-titulo-moderno1'];
var classesMenu = ['menu-01', 'menu-02', 'menu-03'];
var classesTexto = ['textoBranco', 'textoPreto', 'textoCinza'];
function sorteia(arr) {
var rand = Math.floor(Math.random() * arr.length);
return arr[rand];
}
Button code
document.getElementById('troca').addEventListener('click', function() {
var classeRM = sorteia(classesRM);
var classetopoRmt= sorteia(classestopoRmt);
var classemenuRmt= sorteia(classesmenuRmt);
var classeFontTexto = sorteia(classesFontTexto);
var classeFontTitulo = sorteia(classesFontTitulo);
var classeTexto = sorteia(classesTexto);
var classeMenu = sorteia(classesMenu);
var elemento = document.getElementById('navbar');
elemento.className = classemenuRmt;
var elemento = document.getElementById('nav-bar');
elemento.className = classeMenu;
var elemento = document.getElementById('titulo');
elemento.className = classeFontTitulo;
var elemento = document.getElementById('topo');
elemento.className = classetopoRmt;
var elemento = document.getElementById('body');
elemento.className = classeRM + ' ' + classeTexto + ' ' + classeFontTexto;
});
You want me to open a new page or on the same page?
– Sergio
I want you to open in a new page, like the buttons stay on a screen and when you click the generated theme open in a different page without the buttons
– Victor Saul
Okay, and the content of that page is the same as the first?
– Sergio
Yes yes, because this is to be the model, then I manage to get it to open in new page, I already start to see the content
– Victor Saul