jquery 彈出遮罩層
阿新 • • 發佈:2019-02-08
/* 修改密碼是彈出遮罩層 */// url:傳遞aspx頁面// heigth: 彈出頁面顯示高度// width: 彈出頁面顯示寬度function frmMaks(url, heigth, width) { $("body").append("<div class='DivMask'> <iframe src=\"about:blank\" style=\"width:100%;height:100%;filter:Alpha(opacity=0);z-index=-1;\" border=0 frameborder=0></iframe></div>"); $("body").append("<div class=\"fm\"><div style=\"text-align:right;color:red;height:20px;background-color:#DEEFFF; vertical-align:bottom;\" ><a href='#'onclick=\"cose()\">關 閉 </a></div>" + "<iframe frameborder=0 border='0' src=\"" + url + "\" width='100%' height='100%' marginheight='0' marginwidth='0' allowtransparency='true' scrolling='no'></iframe></div>"); SetCss(heigth,width);}function SetCss(heigth,width) { $(".DivMask").css({ position: "absolute", height: Math.max(document.body.scrollHeight, document.documentElement.scrollHeight) + "px", width: Math.max(document.body.scrollWidth, document.documentElement.scrollWidth) + "px", filter: "alpha(opacity=50)", opacity: "0.5", top: "0px", left: "0px", index: "9000px", background: "#CCCCCC", display: "block" }); $(".DivMask").css("-moz-opacity", "0.8"); $(".fm").css({ position: "absolute", height: heigth+"px", width: width + "px", top: (document.body.scrollTop + document.body.clientHeight / 2 - heigth / 2), left: (document.body.scrollLeft + document.body.clientWidth / 2 - width / 2), index: "10000px", display: "block" });}// 關閉層function cose() { $(".DivMask").remove(); $(".fm").remove();}