Well, I need to make clicking a link on one page go to another and only shows the content of the id indicated on the first page, how can I do this? I searched in several places and did not find exactly what I'm looking for.
index.php
<a href="interna.php" onclick="toggle_visibility('bloco1');"></a>
<a href="interna.php" onclick="toggle_visibility('bloco2');"></a>
internal.php
<div id="bloco1" style="display:none">
<div id="bloco2" style="display:none">
This was the javascript I used
<script type="text/javascript">
<!--
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';
}
//-->
</script>
UPDATE Now the blocks are displayed but when I go to the second block all the functionality of the links (eg back button) do not work, only the first block works perfectly. I noticed that in all links the code inserts internal.php? Display = block1 for example, I do not know if this is what is disturbing now.
<a href="interna.php?exibir=bloco1"></a>
<a href="interna.php?exibir=bloco2"></a>
<script>
function queryObj() {
var result = {}, keyValuePairs = location.search.slice(1).split("&");
keyValuePairs.forEach(function(keyValuePair) {
keyValuePair = keyValuePair.split('=');
result[decodeURIComponent(keyValuePair[0])] = decodeURIComponent(keyValuePair[1]) || '';
});
return result;
}
loads content after everything is rendered
$(document).ready(function () {
call method to parse url
var objetoParaOcultar = queryObj();
show the div with the id sent by parameter
$('#' + objetoParaOcultar.exibir).show();
})
</script>