8.7w+
社区成员
function jshFloatBanner(id) {
this.box = document.getElementById(id);
if (this.box.style.top) { this.top = true; this.orgTop = this.box.style.posTop; }
if (this.box.style.bottom) { this.bottom = true; this.orgBottom = this.box.style.posBottom; }
if (this.box.style.left) { this.left = true; this.orgLeft = this.box.style.posLeft; }
if (this.box.style.right) { this.right = true; this.orgRight = this.box.style.posRight; }
this.initBanner();
}
jshFloatBanner.prototype =
{
ae: function(e, call) {
if (window.attachEvent) { window.attachEvent("on" + e, call); }
else if (window.addEventListener) {
window.addEventListener(e, call, false);
}
},
isfixed: !window.ActiveXObject || (navigator.userAgent.indexOf("MSIE 6") == -1 && document.compatMode == "CSS1Compat"), //支持fixed。。ie6以下不支持。其他都支持
fixfun: function() {
var scrollTop = this.de.scrollTop;
var scrollLeft = this.de.scrollLeft;
var winWidth = this.de.clientWidth;
var winHeight = this.de.clientHeight;
var offsetHeight = this.box.offsetHeight;
var offsetWidth = this.box.offsetWidth;
var x, y;
if (this.top) {
y = scrollTop + this.orgTop;
this.box.style.posTop = y;
}
else if (this.bottom) {
if (winHeight + scrollTop > document.body.scrollHeight + offsetHeight) { return; }
y = (scrollTop + winHeight - offsetHeight - this.orgBottom);
this.box.style.posTop = y;
}
if (this.left) {
x = scrollLeft + this.orgLeft;
this.box.style.posLeft = x;
}
else if (this.right) {
if (winWidth + scrollLeft > document.body.scrollWidth + offsetWidth) { return; }
x = (scrollLeft + winWidth - offsetWidth - this.orgRight);
this.box.style.posLeft = x;
this.box.style.posRight = null;
}
},
initBanner: function() {
var o = this;
if (!o.isfixed) {
o.box.style.position = "absolute";
o.de = document.documentElement ? document.documentElement : document.body;
var timer;
o.ae("scroll", function() {
clearTimeout(timer);
timer = setTimeout(function() { o.fixfun(); }, 60)
});
o.ae("resize", function() {
clearTimeout(timer);
timer = setTimeout(function() { o.fixfun(); }, 60)
});
window.scroll();
}
}
}
<div id='div2009_2010' style="position:fixed; bottom: 0; right: 5px; width: 240px;
z-index: 6000; height: 165px; line-height: 100%;">
<span onclick='javascript:parentElement.style.display="none";movepeixun=null;' style="width: 55px; font-size:14px;
right: 0; top: 3px; cursor: pointer; clear: both; line-height: 100%; position: absolute;
font-weight: bold; color: Yellow;">关闭 X</span>
<img src='http://www.fpdisplay.com/Subject/2009-2010meeting/rb2.jpg' alt='' style="cursor: pointer;" onclick='window.open("http://www.fpdisplay.com/Subject/2009-2010meeting/default.html");' />
</div>
<script type="text/javascript">
var right = new jshFloatBanner("div2009_2010");
</script>
fixfun: function() {
var scrollTop = this.de.scrollTop;
var scrollLeft = this.de.scrollLeft;
var winWidth = this.de.clientWidth;
var winHeight = this.de.clientHeight;
var offsetHeight = this.box.offsetHeight;
var offsetWidth = this.box.offsetWidth;
// var x, y;
// if (this.top) {
// y = scrollTop + this.orgTop;
// this.box.style.posTop = y;
// }
// else if (this.bottom) {
// if (winHeight + scrollTop > document.body.scrollHeight + offsetHeight) { return; }
// y = (scrollTop + winHeight - offsetHeight - this.orgBottom);
// this.box.style.posTop = y;
// this.bottom = true;
// }
// if (this.left) {
// x = scrollLeft + this.orgLeft;
// this.box.style.posLeft = x;
// }
// else if (this.right) {
// if (winWidth + scrollLeft > document.body.scrollWidth + offsetWidth) { return; }
// x = (scrollLeft + winWidth - offsetWidth - this.orgRight);
// this.box.style.posLeft = x;
// this.right = true;
// }
//if (this.right) {
// if (winWidth + scrollLeft > parseInt(document.body.scrollWidth)) { return; }
//}
this.box.className = this.box.className;
},
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>测试页面</title>
<script type="text/javascript" src="../js/jquery.js"></script>
<style type="text/css">
</style>
<script type="text/javascript">
var isIE6 = ($.browser.msie && $.browser.version == "6.0");
$(document).ready(function() {
if (isIE6) {
document.getElementById("divFixed").style.position = "absolute";
window.onscroll = function() {
document.getElementById("divFixed").className = document.getElementById("divFixed").className
}
}
});
</script>
</head>
<body style="height:2000px;">
<script type="text/javascript">
</script>
<div id="divFixed" style="width: 200px; height: 200px; border: 2px solid #ff0000;
background-color: #993366; position: fixed; bottom: 10px; right: 10px;">
</div>
<script type="text/javascript">
</script>
</body>
</html>
服务器调试下,看有没执行到fixfun里面去啊