日期:2014-05-17  浏览次数:20996 次

这样的功能怎么实现
比如说页面是这样的
vb         c
当点了vb以后,下面就显示关于vb   的内容,当点了c以后,下面就显示关于c的内容,而页面上其它内容不跟着变

------解决方案--------------------
给你个例子,IE、FF、Opera兼容,自己可以改改

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN ">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME= "Generator " CONTENT= "EditPlus ">
<META NAME= "Author " CONTENT= " ">
<META NAME= "Keywords " CONTENT= " ">
<META NAME= "Description " CONTENT= " ">
<SCRIPT LANGUAGE= "JavaScript ">
<!--
function show(athis,content){
var xy = get(athis);
if(content == 'vb '){
document.getElementById( 'c ').style.display = 'none ';
}else if(content== 'c '){
document.getElementById( 'vb ').style.display = 'none ';
}
content = document.getElementById(content);
content.style.display = 'block ';
content.style.left = xy.x + 'px ';
content.style.top = xy.y + 'px ';
}

function get(element){
var left = element.offsetLeft;
var top = element.offsetTop+element.offsetHeight;
while(element=element.offsetParent){
left += element.offsetLeft;
top += element.offsetTop;
}
return {x:left,y:top};
}
//-->
</SCRIPT>
</HEAD>

<BODY>
<a href= "# " onclick= "show(this, 'vb ') " style= "height:25px;width:100px;border:1px solid #ddd; "> VB </a> <a href= "# " onclick= "show(this, 'c ') " style= "height:25px;width:100px;border:1px solid #ddd; "> C </a>
<br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br>
<div id= "vb " style= "height:50px;position:absolute;z-index:100;display:none;border:1px solid #069;background-color:#ccc "> This is VB Content </div>
<div id= "c " style= "height:50px;position:absolute;z-index:100;display:none;border:1px solid #069;background-color:#ccc "> This is C Content </div>
</BODY>
</HTML>