$(function () {
$(".Loading").css({ "margin": "0px auto", "top": "0px", "min-width": "200px", "width": "auto" });
$(".Loading").parent().css({ "text-align": "center" });
var scroll_top = WhichBro();
if (scroll_top < 100) {
$(".Loading").parent().css({ "position": "fixed", "top": (100 - document.documentElement.scrollTop) + "px", "left": "0px", "z-index": "99999", "width": $(window).width() + "px", "height": "32px", "line-height": "32px", "background-color": "transparent", "display": "none" });
} else {
$(".Loading").parent().css({ "position": "fixed", "top": "0px", "left": "0px", "z-index": "99999", "width": $(window).width() + "px", "height": "32px", "line-height": "32px", "background-color": "transparent", "display": "none" });
}
$(window).scroll(function () {
scroll_top = WhichBro();
if (scroll_top < 100) {
$(".Loading").parent().css({ "position": "fixed", "top": (100 - document.documentElement.scrollTop) + "px", "background-color": "transparent" });
} else {
$(".Loading").parent().css({ "position": "fixed", "top": "0px", "background-color": $(".Loading").css("background-color") });
}
})
$(".Loading").change(function () {
scroll_top = WhichBro();
if (scroll_top < 100) {
$(".Loading").parent().css({ "display": "block", "background-color": "transparent" });
$(".Loading").css({ "display": "inline-block" });
} else {
$(".Loading").parent().css({ "display": "block", "background-color": $(".Loading").css("background-color") });
$(".Loading").css({ "display": "inline-block" });
}
setTimeout('NotVisible()', 10000);
})
$(window).resize(function () {
scroll_top = WhichBro();
if (scroll_top < 100) {
$(".Loading").parent().css({ "position": "fixed", "top": (100 - document.documentElement.scrollTop) + "px", "left": "0px", "z-index": "99999", "width": $(window).width() + "px", "height": "32px", "line-height": "32px", "background-color": "transparent", "display": "none" });
} else {
$(".Loading").css({ "left": ($(window).width() - $(".Loading").width()) / 2 + "px", "top": "0px" });
$(".Loading").parent().css({ "position": "fixed", "top": "0px", "left": "0px", "z-index": "99999", "width": $(window).width() + "px", "height": "32px", "line-height": "32px", "background-color": "transparent", "display": "none" });
}
})
$(".Loading a").click(function () {
$(".Loading").parent().css("display", "none");
})
})
function NotVisible() {
$(".Loading").parent().css("display", "none");
}
function RedirectTo(url) {
setTimeout("window.location.href='" + url + "'", 10000);
}
function WhichBro() {
var scroll_top;
if (document.documentElement && document.documentElement.scrollTop) {
scroll_top = document.documentElement.scrollTop;
}
else if (document.body) {
scroll_top = document.body.scrollTop; /*某些情况下Chrome不认document.documentElement.scrollTop则对于Chrome的处理。*/
}
return scroll_top;
}
html
<div>
<div class="Loading" style="display: none;">
<span id="operateTip">放置提示信息</span> <a href="javascript:void(0)">X</a>
</div>
</div>