如果顶部申明
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
document.body.scrollTop
要改成
document.documentElement.scrollTop
用下面的就可以在鼠标的下面提示一个小框框:
1.//view_window_test 是对像的id 2.//Temo_width 是弹出的DIV的宽度 3.// 20 是 弹出的DIV的高度 4. 5.view_window_test.style.left= event.clientX + document.documentElement.scrollLeft - Temo_width/2; 6.view_window_test.style.top= event.clientY + document.documentElement.scrollTop + 20;
IE5与IE6的区别:
var scrollPos;
if (typeof window.pageYOffset != ’undefined’) {
scrollPos = window.pageYOffset;
}
else if (typeof document.compatMode != ’undefined’ &&
document.compatMode != ’BackCompat’) {
scrollPos = document.documentElement.scrollTop;
}
else if (typeof document.body != ’undefined’) {
scrollPos = document.body.scrollTop;
}
alert(scrollPos);