一、功能
1.鼠标点击发送
2.键盘enter发送
3.隐藏:将运动的消息隐藏 背景图片亮度增强
4.显示:弹幕继续向前运动 背景图片变模糊
二、源代码
<body>
<div id = "box">
<div id= "content"></div>
<p id = "btm">
<span><input type= "text" id="text"/></span>
<span id ="sendCon">send</span>
<span id ="hideCon">hide</span>
<span id ="showCon">show</span>
</p>
</div>
<div id="v">
</div>
</body>
</html>
<script src="sport.js"></script>
<script src="text/javascript">
function $(id){
return document.getElementById(id);
}
function sendMessage(){
var oSpan = document.createElement("span");
oSpan.innerHTML = $("text").value;
$("content").appendChild(oSpan);
oSpan.style.top = Math.floor.(Math.random()*280)+"px";
var oSpanWidth = oSpan.offsetWidth;
startMove(oSpan,{"left":-oSpanWidth},function(){
oSpan.remove();
})
$("text").value = "";
}
$("sendCon").onclick = function(){
sendMessage();
}
document.onkeydown = function(e){
var e = e|| event;
if(e.keyCode = 13){
sendMessage();
}
}
$("hideCon").onclick = function(){
$("content").style.opacity = "0";
$("content").style.filter = 'alpha(opacity = 0)';
}
$("showCon").onclick = function(){
$("content").style.opacity = "1";
$("content").style.filter = 'alpha(opacity = 1)';
</script>