为什么这个代码只能在ie8一下执行,不能再ie10和谷歌和其他的浏览器执行呢?求大神解决下 5
varie=document.all;varnn6=document.getElementById&&!document.all;varisdrag=false;varx...
var ie=document.all;
var nn6=document.getElementById&&!document.all;
var isdrag=false;
var x,y;
var ty=0,tx=0;
var dobj;
function movemouse(e)//鼠标移动 //取画布高度
{
var mywidth = 0;
var che1 = 0;
if (window.innerWidth == undefined)
{
mywidth = document.documentElement.clientWidth;
che1 = document.documentElement.clientHeight;
}else{
mywidth = window.innerWidth - 18;
che1 = window.innerHeight;
}
var che = $("#leftd").height()-30;
if (isdrag)
{
var my_x =100;// nn6 ? tx + e.clientX - x : tx + event.clientX - x;
var my_y = 0;
my_y = nn6 ? ty + e.clientY - y : ty + event.clientY - y;
if(my_y<0){
my_y=0;
}
if(my_y>che1-50){
my_y=che1-50;
}
dobj.style.left = my_x;
dobj.style.top = my_y;
return false;
}
}
function selectmouse(e)//鼠标点击图片移动
{
var fobj = nn6 ? e.target : event.srcElement;
var topelement = nn6 ? "HTML" : "BODY";
try
{
while (fobj.tagName != topelement && fobj.className != "dragme")
{
fobj = nn6 ? fobj.parentNode : fobj.parentElement;
}
if (fobj.className=="dragme")
{
isdrag = true;
dobj = fobj;
tx = parseInt(dobj.style.left+0);
ty = parseInt(dobj.style.top+0);
x = nn6 ? e.clientX : event.clientX;
y = nn6 ? e.clientY : event.clientY;
document.onmousemove=movemouse;
return false;
}
}catch (e)
{
}
}
document.onmousedown=selectmouse;
document.onmouseup=new Function("isdrag=false"); 展开
var nn6=document.getElementById&&!document.all;
var isdrag=false;
var x,y;
var ty=0,tx=0;
var dobj;
function movemouse(e)//鼠标移动 //取画布高度
{
var mywidth = 0;
var che1 = 0;
if (window.innerWidth == undefined)
{
mywidth = document.documentElement.clientWidth;
che1 = document.documentElement.clientHeight;
}else{
mywidth = window.innerWidth - 18;
che1 = window.innerHeight;
}
var che = $("#leftd").height()-30;
if (isdrag)
{
var my_x =100;// nn6 ? tx + e.clientX - x : tx + event.clientX - x;
var my_y = 0;
my_y = nn6 ? ty + e.clientY - y : ty + event.clientY - y;
if(my_y<0){
my_y=0;
}
if(my_y>che1-50){
my_y=che1-50;
}
dobj.style.left = my_x;
dobj.style.top = my_y;
return false;
}
}
function selectmouse(e)//鼠标点击图片移动
{
var fobj = nn6 ? e.target : event.srcElement;
var topelement = nn6 ? "HTML" : "BODY";
try
{
while (fobj.tagName != topelement && fobj.className != "dragme")
{
fobj = nn6 ? fobj.parentNode : fobj.parentElement;
}
if (fobj.className=="dragme")
{
isdrag = true;
dobj = fobj;
tx = parseInt(dobj.style.left+0);
ty = parseInt(dobj.style.top+0);
x = nn6 ? e.clientX : event.clientX;
y = nn6 ? e.clientY : event.clientY;
document.onmousemove=movemouse;
return false;
}
}catch (e)
{
}
}
document.onmousedown=selectmouse;
document.onmouseup=new Function("isdrag=false"); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询