homepage button - javascript

Asked

Viewed 39 times

0

I am trying to get a button, on click, to return the user to the home page.

Since I am mostly working with Javascript (I cannot use j-query), I am creating functions that delete the current elements and present the elements corresponding to the home page.

However, it’s not working. Nor do I understand how to have this function on all "pages" (it’s just an HTML page).

javascript page "homepage"

function showPagina2(){

var historias = document.getElementById("historias");

var hist1 = document.getElementById("hist1");
hist1.id="hist1";
hist1.style.opacity = "0.0";
historias.appendChild(hist1);

var hist2 = document.getElementById("hist2");
hist2.id="hist2";
hist2.style.opacity = "0.0";
historias.appendChild(hist2);

var hist3 = document.getElementById("hist3");
hist3.id="hist3";
hist3.style.opacity = "0.0";
historias.appendChild(hist3);

var textoabrigo= document.getElementById("textoabrigo");
textoabrigo.id="textoabrigo";
textoabrigo.style.opacity = "0.0";
historias.appendChild(textoabrigo);



showHeader();
startFadeInPagina2();

}



 function showDivPagina2(){

var div2 = document.getElementById('historias').style.visibility = 
 "visible";

 }

 //esconder div histórias do início 

function divHistorias() {
var x = document.getElementById('historias');
if (x.style.visibility === 'hidden') {
    x.style.visibility = 'visible';
} else {
    x.style.visibility = 'hidden';
}
}

HTML

when clicking logoheader, the contents present should disappear and present the homepage. I can make things go away, but I can’t bring the initial.

<div id="header">
<button id="logoheader" onclick="hideDivHistorias(); showPagina2(); 
showDivPagina2();">
<img width= 150px src="image/logo.png">
</button>
</div>
  • It’s pretty messed up, huh?

  • yes :( until because I don’t know if what I want to do is possible. I’m not from this "world," it’s a college job, so even the simplest things seem impossible ahah

  • Wouldn’t it be simpler just to create one <a> with href="/"?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.