素材图片酷
图酷镜像二
|
壁纸酷
壁纸镜像二
|
写真扫图酷
|
Free Wallpaper
|
贴图论坛
|
·设为首页
·加入收藏
|
网站首页
|
自习室
|
矢量图
|
壁纸酷
|
美术馆
|
封套秀
|
海报馆
|
图标库
|
插画本
|
设计赏
|
小黑板
|
酷论坛
|
您现在的位置:
图酷
>>
自习室
>>
网页设计
>>
Javascript
>> 教程正文
没有公告
JS+CSS打造可拖动的聊天窗口层
作者:
佚名
教程来源:
不详
教程等级:
★★★
教程录入:
烤焦面包
教程审核:
tucoo
添加时间:
2007-1-24
点击次数:
字体选择:
【字体:
小
大
】
相关操作:
【
发表评论
】【
加入收藏
】【
告诉好友
】【
打印此文
】【
关闭窗口
】
热门信息:
推荐内容:
一个可以拖动的聊天窗口层,兼容IE和FF:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=gb2312"> <meta http-equiv="content-script-type" content="text/javascript"> <meta http-equiv="content-style-type" content="text/CSS"> <title>DoDi Chat v1.0 Beta</title> <style rel="stylesheet" type="text/css" media="all" /> <!-- body { text-align:left; margin:0; font:normal 12px Verdana, Arial; background:#FFEEFF } form { margin:0; font:normal 12px Verdana, Arial; } table,input { font:normal 12px Verdana, Arial; } a:link,a:visited{ text-decoration:none; color:#333333; } a:hover{ text-decoration:none; color:#FF6600 } #main { width:400px; position:absolute; left:600px; top:100px; background:#EFEFFF; text-align:left; filter:Alpha(opacity=90) } #ChatHead { text-align:right; padding:3px; border:1px solid #003399; background:#DCDCFF; font-size:11px; color:#3366FF; cursor:move; } #ChatHead a:link,#ChatHead a:visited, { font-size:14px; font-weight:bold; padding:0 3px } #ChatBody { border:1px solid #003399; border-top:none; padding:2px; } #ChatContent { height:200px; padding:6px; overflow-y:scroll; word-break: break-all } #ChatBtn { border-top:1px solid #003399; padding:2px } --> </style> <script language="javascript" type="text/javascript"> <!-- function $(d){return document.getElementById(d);} function gs(d){var t=$(d);if (t){return t.style;}else{return null;}} function gs2(d,a){ if (d.currentStyle){ var curVal=d.currentStyle[a] }else{ var curVal=document.defaultView.getComputedStyle(d, null)[a] } return curVal; } function ChatHidden(){gs("ChatBody").display = "none";} function ChatShow(){gs("ChatBody").display = "";} function ChatClose(){gs("main").display = "none";} function ChatSend(obj){ var o = obj.ChatValue; if (o.value.length>0){ $("ChatContent").innerHTML += "<strong>Akon说:</strong>"+o.value+"<br/>"; o.value=''; } } if (document.getElementById){ ( function(){ if (window.opera){ document.write("<input type='hidden' id='Q' value=' '>"); } var n = 500; var dragok = false; var y,x,d,dy,dx; function move(e) { if (!e) e = window.event; if (dragok){ d.style.left = dx + e.clientX - x + "px"; d.style.top = dy + e.clientY - y + "px"; return false; } } function down(e){ if (!e) e = window.event; var temp = (typeof e.target != "undefined")?e.target:e.srcElement; if (temp.tagName != "HTML"|"BODY" && temp.className != "dragclass"){ temp = (typeof temp.parentNode != "undefined")?temp.parentNode:temp.parentElement; } if('TR'==temp.tagName){ temp = (typeof temp.parentNode != "undefined")?temp.parentNode:temp.parentElement; temp = (typeof temp.parentNode != "undefined")?temp.parentNode:temp.parentElement; temp = (typeof temp.parentNode != "undefined")?temp.parentNode:temp.parentElement; } if (temp.className == "dragclass"){ if (window.opera){ document.getElementById("Q").focus(); } dragok = true; temp.style.zIndex = n++; d = temp; dx = parseInt(gs2(temp,"left"))|0; dy = parseInt(gs2(temp,"top"))|0; x = e.clientX; y = e.clientY; document.onmousemove = move; return false; } } function up(){ dragok = false; document.onmousemove = null; } document.onmousedown = down; document.onmouseup = up; } )(); } --> </script> </head> <body> <div id="main" class="dragclass" style="left:600px;top:300px;"> <div id="ChatHead"> <a href="#" onclick="ChatHidden();">-</a> <a href="#" onclick="ChatShow();">+</a> <a href="#" onclick="ChatClose();">x</a> </div> <div id="ChatBody"> <div id="ChatContent"></div> <div id="ChatBtn"> <form action="" name="chat" method="post"> <textarea name="ChatValue" rows="3" style="width:350px"></textarea> <input name="Submit" type="button" value="Chat" onclick="ChatSend(this.form);" /> </form> </div> </div> </div> </body> </html>
上一篇教程:
网页javascript精华代码集
下一篇教程:
Js之软键盘实现(源码)
::版权和投稿说明::
任何媒体、网站或个人转载、链接、转贴或以其他方式复制发表本站文章,在使用时务必注明“
稿件来源:图酷
”及“
www.tucoo.com
”字样,多谢。
本站已注明“来源”的文章均为转载稿,本站转载出于传递更多信息之目的。如本站转载稿涉及版权等问题,请来信与本站联系。
如果您有自己原创的作品,请向我们投稿哦!您可以通过Email:
gogocat@21cn.com
投出自己的作品,赶快行动吧!
如果觉得我们的资源有用,请推荐给朋友,谢谢!
::相关教程::
javascript模拟的DOS窗口
利用javascript从数据库取数据来实现CSDN首页图片…
将js文件编译成动态链接库(dll)文件
document.onLoad的触发时间
javascript实现的自动验证函数
javascript弹出窗口问题总结
网站繁简转换解决方案--ASP,JSP,PHP,.Net通用
在b/s开发中经常用到的javascript技术
网友评论:
(评论内容只代表网友观点,与本站立场无关!)
【
发表评论
】
|
设为首页
|
加入收藏
|
联系站长
|
友情链接
|
网站公告
|
版权申明
|
管理登录
|
网站制作维护:
烤焦面包