3 回答
TA贡献1836条经验 获得超5个赞
函数声明中有语法错误(缺少括号):
function getContent {
document.getElementById("contentFrame").src="LoremIpsum.html";
}
应:
function getContent() {
document.getElementById("contentFrame").src="LoremIpsum.html";
}
还需要防止链接的默认事件。
<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(event) {
event.preventDefault();
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(event)'> LoremIpsum</a></li>
</ul>
<!-- <button onclick="getContent()">Lorem Ipsum</button> -->
</div>
<iframe class="content" id="contentFrame" src="dummy.html">
</iframe>
</body>
添加回答
举报