【发布时间】:2011-11-17 02:43:26
【问题描述】:
我想制作一个包含两个 iframe 的内容页面。一个 iframe 是带有按钮或链接的浮动侧边菜单,而另一个 iframe 实际上包含内容。我希望用户能够单击侧面菜单上的链接,例如“图像”,然后让该链接更改另一个 iframe 的内容。我还希望当鼠标悬停在菜单上的每个标签(图像、主页、读数)上时,整个单元格都会改变颜色。
我尝试了很多东西,但这里是代码的基础:
<html>
<head>
<title>Main Content Page</title>
</head>
<body background="background.jpg">
<table>
<th>
<iframe src="sidebar.html" frameborder="no" border="0" scrolling="no" height="750" width="450"></iframe>
<th>
<iframe id ="content" src="" frameborder="no" border="0" scrolling="no" width="600" height="800"></iframe>
</table>
</body>
</html>
然后内容 iframe 的页面无关紧要。侧边栏的代码是:
<html>
<head>
<title>Main</title>
<base target="content">
<style type="text/css">
body{bgcolor: black;}
a{color: white}
a:link, a:visited{background-color: black}
<!--a:hover{background-color: gray}-->
<!--td:hover{background-color: gray}-->
buttons:hover{background-color: gray}
td, th{border:1px solid black; background-color:black;}
table{border:1px solid gray;}
td {font-family: Kunstler Script; color: white; font-size: 72; padding:15px;}
</style>
</head>
<body>
<table align="center">
<tr><div class="buttons"><div><td onclick="target.content.home.href='html'">Home</div>
<tr><div><td onclick="target.content.href='images.html'">Images</div>
<tr><div><td onclick="target.content.href='readings.html'">Readings</div></div>
</table>
</div>
</body>
</html>
现在链接不起作用,但按钮会改变颜色
【问题讨论】:
-
好吧,别这样,使用CSS固定定位jsfiddle.net/HerrSerker/fC2Zf
标签: javascript html iframe