兼容ie ff 浮动层实现方法
body
{
font: 12px arial, helvetica, sans-serif;
}
a
{
text-decoration: none;
}
a:hover
{
color: red;
}
function chathidden() {
document.getelementbyid("div2").style.display = "none";
document.getelementbyid("movedivid").style.;
}
function chatshow() {
document.getelementbyid("movedivid").style.display = "block";
document.getelementbyid("movedivid").style.;
document.getelementbyid("div2").style.display = "block";
}
function chatclose() {
document.getelementbyid("movedivid").style.display = "none";
}
var drag_ = false
var d = new function('obj', 'return document.getelementbyid(obj);');
var oevent = new function('e', 'if (!e) e = window.event;return e');
function move_obj(obj) {
var x, y;
d("main").onmousedown = function(e) {
drag_ = true;
with (this) {
d("main").style.position = "absolute";
var temp1 = d("movedivid").offsetleft; //距离左边的初始值
var temp2 = d("movedivid").offsettop; //距离顶边的初始值
x = oevent(e).clientx;
y = oevent(e).clienty;
document.onmousemove = function(e) {
if (!drag_) {
return false;
}
with (this) {
d("movedivid").style.left = temp1 + oevent(e).clientx - x + "px"; //层离左边距的像素
d("movedivid").style.top = temp2 + oevent(e).clienty - y + "px"; //层离顶部距的像素
}
}
}
document.onmouseup = new function("drag_=false");
}
}