1
In this work of the facul, estu making an app with several menus, if I do everything in a single html, will get huge file. So by clicking the options on a given menu, I would like to continue running the app with another html document, loaded instead of the current one. I could do with html with something like: < a href..... /> right?
But I would like to do this within a javascript function, which is triggered by clicking a button on a menu. Follow the snippet of my code:
<div class="menu" id="menuCorNaoCor" style="display:none">
<div class="centralizar">
<button class="botao" onClick="carregarMenuCorrentista()"> Correntista </button>
<button class="botao" > Não Correntista </button>
</div>
</div>
<script>
function carregarMenuCorrentista(){
//Carrega o menu, que está em outro documento html
}
</script>
I will load it centered, in the middle of the page, instead of the current one. I have a css file that does this formatting for menus already. The point is just that I didn’t want to put this menu in the same doc html, which is already getting big.
– Lucas Pletsch
Yes, you want to load content from another page into the
<div class="centralizar">
?– Sam
It is, in a way. But this, only at the click of the Merchant button for example.
– Lucas Pletsch
I’ll edit the question so you can see how it looks... it’s much better to do this, because you’ll have to use ajax
– Sam
:Can you do it with ajax? I haven’t seen it yet.
– Lucas Pletsch
If you don’t want to leave the current page and just upload content from another page, the best is Ajax.
– Sam
This last option
– Lucas Pletsch
So you don’t even need function, just put
onclick="location.href='pagina.html'";
– Sam
No. I got confused. kkk. I didn’t want to have to load another page.
– Lucas Pletsch
From what I understand, you want to make a layout and when opening a link from the menu, upload the content of the link within the page itself, without having to copy the entire layout on each page of your site/app, right? If yes, I can answer your question with an ajax solution, as mentioned by @dvd.
– LipESprY