我正在尝试为我的网站开发一个聊天框。
<div class="chat_box1">
<div id="chat_box_bar">
<p>(SOME PHP CODE HERE)</p>
<p id="close_chat" onclick="close_chat_box(1)">X</p>
</div>
</div>
我想知道我是否将显示设置为“无”,并且只有在单击某些文本时才能将其更改为“阻止”。作为:
<li onclick='display_chat_box(chat_box_number(),"kamal@kamal.com")'>KAMAL</li>
javascript函数:
function display_chat_box(y,email)
{
switch (y)
{
case 1:
{
alert("hi");
document.getElementsByClass("chat_box1")[0].style.display="block";
}
case 2:
{
document.getElementsByClass("chat_box2")[0].style.display="block";
}
case 3:
{
document.getElementsByClass("chat_box3")[0].style.display="block";
}
}
}
我在第一种情况下插入了警报代码,以检查范围内的代码是否有效,并且它在我运行网页时弹出警报框。
问题:显示属性没有从“无”变为“阻止”。不知道为什么,但它以某种方式在我之前正在使用的另一台 PC 上运行。
变量 'y' 从这个函数中获取它的值:
function chat_box_number()
{
if(n==3)
n=0;
n++;
return n;
}
这是CSS代码:
.chat_box1,.chat_box2,.chat_box3
{
display: none;
width: 20%;
position: fixed;
bottom:0;
margin-right: 10px;
border-style: solid;
border-width: thin;
height:30%;
font-family: comic sans ms;
font-size: 12px;
}
请帮忙。