//背景css: #fullbg{ position:absolute; cursor:pointer; background-color: #000000; display: none; z-index: 100; left: 0px; top: 0px; filter: Alpha(Opacity=50); -moz-opacity: 0.5; opacity: 0.5; } //彈出背景html: <div id="fullbg"></div> //彈出框div的id: tishi_info
//彈出js函數:
function show_tishi()
{
var bH = $(document).height();
var bW = $(document).width();
$("#fullbg").css({ width: bW, height: bH, display: "block" });
var x=$(window).width()/2;
var y=$(window).height()/2;
var div_w=$("#tishi_info").width()/2;
var div_h=$("#tishi_info").height()/2;
var stop=document.documentElement.scrollTop;
var sleft=$("tishi_info").scrollLeft();
var left=x-div_w+sleft+"px";
var top=y-div_h+stop+"px";
$("#tishi_info").css({"position": "absolute",left:left,top:top});
$("#tishi_info").show('block');
}