I'm doing a job for college in which I have to make a website in HTML as if it were from a company.
In the right column I intend to put links that would load other pages in the empty area but without reloading the whole page
The simplest way is to use iframe , but you can use jQuery, XMLHttpRequest, etc.
var menu = document.querySelectorAll("nav ul li a");
var iframe = document.querySelector("iframe");
menu.forEach(function(el) {
el.addEventListener("click", function(e) {
e.preventDefault();
alert("Nesse site não vai funcionar");
iframe.src = el.getAttribute("href");
});
});
* {
padding: 0;
margin: 0;
}
nav ul {
list-style-type: none;
width: 100%
}
nav ul li {
float:left;
margin-left: 20px;
padding: 20px;
background:#CCC;
}
iframe {
float:left;
height: 300px;
width: 90%;
}
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<nav>
<ul>
<li><a href="https://www.google.com.br">Google</a></li>
<li><a href="https://fb.com">Facebook</a></li>
<li><a href="https://twitter.com">Twitter</a></li>
</ul>
</nav>
<iframe src="/"></iframe>
</body>
</html>