I have a pretty simple page with sidebar navigation and an iFrame for loading content.
I want to change the contents of an iFrame by clicking the links in the sidebar of nav. I am using javascript to change the source (.src) of document.element.
I read a lot of articles (StackOverflow), and the code should work, but just doesn't work.
Below is the html code I created and it includes JS in the tag.
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
<link href="css/default.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
function getContent{
document.getElementById("contentFrame").src="LoremIpsum.html";
}
</script>
</head>
<body>
<div class="sidebar"><h1>Technical Documentation</h1>
<ul>
<li>Configuration Guides</li>
<li>API Guides</li>
<li><a href="" onclick='getContent()'> LoremIpsum</a></li>
</ul>
</div>
<iframe class="content" id="contentFrame" src="dummy.html">
</iframe>
</body>
source
share