好的,我已经在这个网页上工作了一个星期,并且碰壁了。除了让 getelementbyid 起作用之外,代码已经到位。当您在侧边栏中选择图像时,我正在尝试通过更改 javascript 源来更改框架 div 中的图像。我想知道的是我的代码中是否存在问题,或者该函数是否无法正常工作。
<head>
<title>Rivas2</title>
<script id="newset" src="sidescroll.js" type="text/javascript"></script>
<script type= "text/javascript">
function changesrc() {
var sets = document.getElementById('newset');
switch (value) {
case '1': sets.src = 'sidescroll.js'; break;
case '2': sets.src = 'sidescroll2.js'; break;
}
}
</script>
<style type="text/css">
body{
background-color:#66FFFF;
}
.banner{
position:absolute;
top: 15px;
left: 300px;}
.sideb1{
position:absolute;
top: 120px;
left: 25px;
height: 530px;
width: 150px;
overflow: auto;}
.frame{
position:absolute;
top: 120px;
left: 400px;}
.scroll{
position: absolute;
top: 525px;
left: 400px;
}
</style>
</head>
<div class="sideb1" >
<input type = 'image' src = 'image3.jpg' onclick = 'changesrc(1)' width= "120" height= "100" alt= " " /><br/> House 1<br/>
<input type = 'image' src = 'image3.jpg' onclick = 'changesrc(2)' width= "120" height= "100" alt= " " /><br/> House 2<br/>
<a href="rivas2.html" ><img src="image3.jpg" width= "120" height= "100" alt="" /> </a><br/> House 3<br/>
<a href="rivas3.html" ><img src="image3.jpg" width= "120" height= "100" alt="" /> </a><br/> House 4<br/>
<a href="rivas2.html" ><img src="image3.jpg" width= "120" height= "100" alt="" /> </a><br/> House 5<br/>
</div>