js代码中block也改成inline,再试试 <script type="text/javascript"> function ShowQy() {//visibility:visible var oTb=document.getElementById('GR'); var oqy=document.getElementById('QY'); oTb.style.display="none"; oqy.style.display="block"; } function ShowGr() { var oTb=document.getElementById('GR'); var oqy=document.getElementById('QY'); oTb.style.display="block"; oqy.style.display="none"; } //页面加载的时候 function ShowLogin() { var oTb=document.getElementById('GR'); var oqy=document.getElementById('QY'); oTb.style.display="block"; oqy.style.display="none"; } </script>
个人会员的
<tr>
<td valign="top" height="135px;">
<div id="GR" style="width: 200px;border: 1px solid #CCC;background-color: #f7f7f7; z-index:0px;">
....
</div>
</td>
</tr>
企业会员的
<tr>
<td valign="top" height="135px;">
<div id="Qy" style="width: 200px;border: 1px solid #CCC;background-color: #f7f7f7; z-index:0px;">
....
</div>
</td>
</tr>
dispaly
visibility
<div id="GR" style="width: 200px;border: 1px solid #CCC;background-color: #f7f7f7;" >
<table width="240" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/index_09_01.jpg" width="125" height="45" border=0 /><img src="images/index_09_02.jpg" width="131" height="45" border=0 onclick="document.getElementById('GR').display='none';document.getElementById('QY').display='block';" /></td>
</tr>
</div>
企业会员
<div id="QY" style="width: 200px; border: 1px solid #CCC; background-color: #f7f7f7; display:none;">
<table width="240" border="0" cellspacing="0" cellpadding="0" >
<tr>
<td><img src="images/222222.jpg" width="125" height="45" border=0 onclick="document.getElementById('QY').display='none';document.getElementById('GR').display='block';" /><img src="images/111111.jpg" width="131" height="45" border=0 /></td>
</tr>
</div>
这个是的JS 代码<script type="text/javascript">
function ShowQy()
{//visibility:visible
var oTb=document.getElementById('GR');
var oqy=document.getElementById('QY');
oTb.style.display="none";
oqy.style.display="block";
}
function ShowGr()
{
var oTb=document.getElementById('GR');
var oqy=document.getElementById('QY');
oTb.style.display="block";
oqy.style.display="none";
}
//页面加载的时候
function ShowLogin()
{
var oTb=document.getElementById('GR');
var oqy=document.getElementById('QY');
oTb.style.display="block";
oqy.style.display="none";
}
</script>个人会员
<div id="GR" style="width: 200px;border: 1px solid #CCC;background-color: #f7f7f7;" >
<table width="240" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/index_09_01.jpg" width="125" height="45" border=0 /><img src="images/index_09_02.jpg" width="131" height="45" border=0 onclick="ShowQy();" /></td>
</tr>
</div>企业会员
<div id="QY" style="width: 200px; border: 1px solid #CCC; background-color: #f7f7f7;">
<table width="240" border="0" cellspacing="0" cellpadding="0" >
<tr>
<td><img src="images/222222.jpg" width="125" height="45" border=0 onclick="ShowGr();" /><img src="images/111111.jpg" width="131" height="45" border=0 /></td>
</tr>
</div>
<div id="GR" style="width: 200px;border: 1px solid #CCC;background-color: #f7f7f7;" >
<table width="240" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/index_09_01.jpg" width="125" height="45" border=0 /><img src="images/index_09_02.jpg" width="131" height="45" border=0 onclick="ShowQy();" /></td>
</tr>
</div>
少了个</table>
<div id="QY" style="width: 200px; border: 1px solid #CCC; background-color: #f7f7f7; display:inline;">
<script type="text/javascript">
function ShowQy()
{//visibility:visible
var oTb=document.getElementById('GR');
var oqy=document.getElementById('QY');
oTb.style.display="none";
oqy.style.display="block";
}
function ShowGr()
{
var oTb=document.getElementById('GR');
var oqy=document.getElementById('QY');
oTb.style.display="block";
oqy.style.display="none";
}
//页面加载的时候
function ShowLogin()
{
var oTb=document.getElementById('GR');
var oqy=document.getElementById('QY');
oTb.style.display="block";
oqy.style.display="none";
}
</script>
<div id="GR" style="width: 200px;border: 1px solid #CCC;background-color: #f7f7f7;" >
<table width="240" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/index_09_01.jpg" width="125" height="45" border=0 /><img src="images/index_09_02.jpg" width="131" height="45" border=0 onclick="ShowQy();" /></td>
</tr>
</table>
</div>
<div id="QY" style="width: 200px; border: 1px solid #CCC; background-color: #f7f7f7;">
<table width="240" border="0" cellspacing="0" cellpadding="0" >
<tr>
<td><img src="images/222222.jpg" width="125" height="45" border=0 onclick="ShowGr();" /><img src="images/111111.jpg" width="131" height="45" border=0 /></td>
</tr>
</table>
</div>
下面是
个人会员的Div
<div id="GR" style="width: 200px;border: 1px solid #CCC;background-color: #f7f7f7; display:inline;" >
<table width="240" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/index_09_01.jpg" width="125" height="45" border=0 /><img src="images/index_09_02.jpg" width="131" height="45" border=0 onclick="ShowQy();" /></td>
</tr>
<tr>
<td height="99" background="images/index_12.gif"><table width="230" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><table width="220" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="172"><table width="170" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50" height="28">用户名</td>
<td height="28">
<asp:TextBox ID="BJUserInfo_Title" MaxLength="12" runat="server" Width="118px"></asp:TextBox>
</td>
</tr>
<tr>
<td width="50" height="28">密 码</td>
<td height="28">
<asp:TextBox ID="BJUserInfo_PassWord" TextMode="Password" MaxLength="16" runat="server" Width="117px"></asp:TextBox>
</td>
</tr>
</table></td>
<td width="48">
<asp:ImageButton ID="ImageButton1" ImageUrl="images/login.jpg" runat="server" width="48" height="48" Border=0 OnClick="ImageButton1_Click" />
</td>
</tr>
</table></td>
</tr>
<tr align="center">
<td>
<asp:ImageButton ID="ImageButton2" ImageUrl="images/zc.jpg" width="92" height="25" runat="server" border=0 OnClick="ImageButton2_Click" />
<asp:ImageButton ID="ImageButton3" ImageUrl="images/mm.GIF" runat="server" width="81" height="25" OnClick="ImageButton3_Click" />
</td>
</tr>
</table></td>
</tr>
</table>
</div>
<table width="240" border="0" cellspacing="0" cellpadding="0" >
<tr>
<td><img src="images/222222.jpg" width="125" height="45" border=0 onclick="ShowGr();" /><img src="images/111111.jpg" width="131" height="45" border=0 /></td>
</tr>
<tr>
<td height="99" background="images/index_12.gif"><table width="230" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><table width="220" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="172"><table width="170" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50" height="28">用户名</td>
<td height="28">
<asp:TextBox ID="BJEnterPrize_EnterPrizeName" runat="server" MaxLength="12" Width="118px"></asp:TextBox>
</td>
</tr>
<tr>
<td width="50" height="28">密 码</td>
<td height="28">
<asp:TextBox ID="BJEnterPrize_Password" runat="server" MaxLength="16" Width="117px" TextMode="Password"></asp:TextBox>
</td>
</tr>
</table></td>
<td width="48">
<asp:ImageButton ID="ImgQy" ImageUrl="images/login.jpg" runat="server" width="48" height="48" Border=0 OnClick="ImgQy_Click" />
</td>
</tr>
</table></td>
</tr>
<tr align="center">
<td>
<asp:ImageButton ID="Qyzc" ImageUrl="images/zc.jpg" width="92" height="25" runat="server" border=0 OnClick="Qyzc_Click" />
<asp:ImageButton ID="QyPwd" ImageUrl="images/mm.GIF" runat="server" width="81" height="25" OnClick="QyPwd_Click" />
</td>
</tr>
</table></td>
</tr>
</table>
</div>顺便问下还有其它的方法吗
--------->
.display=''试一下
不清楚是由于什么原因不过可以换个思路,可以利用table的tr显示、隐藏
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>1</title>
<script type="text/javascript">
function ShowTr(num)
{
if(num==1){
document.getElementById("tr1").style.display="block";
document.getElementById("tr2").style.display="none";
document.getElementById("img1").src = "images/index_09_01.jpg";
document.getElementById("img2").src = "images/index_09_02.jpg";
}else{
document.getElementById("tr2").style.display="block";
document.getElementById("tr1").style.display="none";
document.getElementById("img1").src = "images/222222.jpg";
document.getElementById("img2").src = "images/111111.jpg";
}
}
</script>
</head>
<body>
<table width="200px" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<img id="img1" src="images/index_09_01.jpg" width="120" height="45" border=0 onclick="ShowTr(1);"/><img id="img2" src="images/index_09_02.jpg" width="120" height="45" border=0 onclick="ShowTr(2);" />
</td>
</tr>
<tr id=tr1>
<td>11111</td>
</tr>
<tr id=tr2 style="display:none">
<td>22222</td>
</tr>
</table>
</body>
</html>
<% if(登陆成功的条件){ %>
html代码
<% }else {%>
html代码
<% } %>
通过这样的方法规避,显示和隐藏的问题,而是通过条件去执行还是不执行html代码来实现。