Js+css to create a drag-and-drop Chat window layer

Source: Internet
Author: User
Tags return tagname window
Css|js| can be dragged

A layer of chat windows that can be dragged, compatible with IE and FF:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "><ptml xmlns=" http://www.w3.org/1999/xhtml "><pead> <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.defaultv Iew.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 said:</strong>" +o.value+ "<br/> "; O.value= '; } if (document.getElementById) {(function () {if (Window.opera) {document.write ("<input type= ' Hidde N ' 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.parentEl ement; 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)) | DY = parseint (GS2 (temp, top)) | 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></pead><body><div id= "main" class= "Dragclass" style= "left:600px;top:300px"; > <div id= "chathead" > <a href= "#" >-</a> <a href= "#" >+</a> <a href= "#" > x</a> </div> <div id= "Chatbody" > <div id= "chatcontent" ></div> <div id= "Chatbtn" &G T <form action= "" name= "chat" method= "post" > <textarea name= "chatvalue" rows= "3" style= "width:350px" ></t extarea> <input name= "Submit" type= "button" value= "Chat"/> </form> </div> </div&gt ;</div></body></ptml>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.