<script>
//float
$.fn.smartFloatt = function () {
var position = function (element) {
var top = element.position().top, pos = element.css("position");
$(window).scroll(function () {
var scrolls = $(this).scrollTop();
if (scrolls > (top - 200)) {
if (window.XMLHttpRequest) {
element.css({
position: "fixed",
top: 200
});
} else {
element.css({
top: scrolls
});
}
} else {
element.css({
position: pos,
top: top
});
}
});
};
return $(this).each(function () {
position($(this));
});
};
function hidead() {
document.getElementById("sidebar_w").style.visibility = "hidden";
}
</script>
<div class="sidebar_w" id="sidebar_w" style="position: absolute; left: 5px; top: 200px;">
<img src="../images/2010279242.png" /><br />
<div style="text-align: center;">
<img src="../images/close.gif" style="cursor: pointer;" alt="点击 关闭" onclick="hidead()" /></div>
</div>
<script type="text/javascript">
$(".sidebar_w").smartFloatt();
</script>
点击预览