JS offsetX 与 火狐兼容问题
简介:
JS offsetX 与 火狐 兼容问题
火狐 好像不支持 offsetX 下面这段代码中的offsetX 该怎么改,在火狐 下,才能好用呢?function upNext(bigimg){var lefturl = 'javascript:dPlayPre();';var righturl...
JS offsetX 与 火狐 兼容问题
-
JScript code
-
function
upNext(bigimg){
var
lefturl
=
'
javascript:dPlayPre();
'
;
var
righturl
=
'
javascript:dPlayNext();
'
;
var
imgurl
=
righturl;
var
width
=
bigimg.width;
var
height
=
bigimg.height;
bigimg.onmousemove
=
function
(evt){
evt
=
evt
?
evt : (window.event
?
window.event :
null
);
var
fx
=
evt.offsetX
||
evt.layerX;
if
(fx
<
width
/
2){
bigimg.style.cursor
=
'
url(/images/arr_left.cur),auto
'
;
imgurl
=
lefturl;
}
else
{
bigimg.style.cursor
=
'
url(/images/arr_right.cur),auto
'
;
imgurl
=
righturl;
}
}
bigimg.onmouseup
=
function
(){
top.location
=
imgurl;
}
}
参考:http:
//
blog.csdn.net/IBM_hoojo/archive/2010/07/02/5708440.aspx
下面这段代码中的 offsetX 该怎么改,在 火狐 下,才能好用呢?
function upNext(bigimg){
var lefturl = 'javascript:dPlayPre();';
var righturl = 'javascript:dPlayNext();';
var imgurl = righturl;
var width = bigimg.width;
var height = bigimg.height;
bigimg.onmousemove=function(evt){
evt = evt ? evt : (window.event ? window.event : null);
if(evt. offsetX <width/2){
bigimg.style.cursor = 'url(/images/arr_left.cur),auto';
imgurl = lefturl;
}
else{
bigimg.style.cursor = 'url(/images/arr_right.cur),auto';
imgurl = righturl;
}
}
bigimg.onmouseup=function(){
top.location=imgurl;
}
}