After being very helpfully pointed to AJAX and jquery as an answer to an earlier question, I found much helpful documentation, examples and questions. Particularly this...
Replace innerhtml with external page
But after banging my head against a brick wall for what seems like forever, I just can't get it to work! Hopefully it's something glaringly obvious to you guys! Again, thanks in advance!
Here's what I have...
<head>
<link rel="stylesheet" type="text/css" href="css/new1.css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(
function navclick(which) {
$('#container').load(which + '.html');
}
)
</script>
</head>
<body id="main">
<div>
<a href="javascript: void(0)" onclick="navclick('page1')">Page 1</a>
<a href="javascript: void(0)" onclick="navclick('page2')">Page 2</a>
</div>
<div id="container">
<p>Placeholder text</p>
</div>
</body>
file:///. Use a local webserver instead so you can serve overhttp://. And also do what Taplar said in the first comment - that will remove your Uncaught Reference error. There's no need to define a function within document.ready, since it won't be executed until it's called anyway. document.ready is only to stop code which would normally be executed immediately it was loaded, from executing until the DOM is fully complete.