標籤:pointer tail src ext 設定 思路 item cli ref
如果點擊iframe中的image顯示整個頁面的遮罩層,可參考如下:
http://blog.csdn.net/shiaijuan1/article/details/70160714
具體思路就是,頂層添加dom對象,用來顯示資訊,預設隱藏,需要時在iframe中調用,寬高設定為100%。
實現如下:
//遮罩層 .showmask { position: fixed; z-index: 99; width: 100%; height: 100%; background-color: silver; top: 0px; left: 0px; opacity: 0.5; } .showmasklayer { position: absolute; z-index: 168; top: 0px; left: 0px; min-width: 100%; min-height: 100%; display: flex; justify-content: center; align-items: center; } //關閉按鈕 .showmaskclose { background-color: red; color: white; border: 2px solid gray; position: fixed; z-index: 288; top: 0px; right: 0px; cursor: pointer; height: 30px; width: 30px; font-size: large; font-weight: bold; text-align: center; display: flex; justify-content: center; align-items: center; }
iframe中調用如下:
$(function () { $("#image").on("click", function () { //判斷是否已經添加過遮罩層dom if ($(".showmaskclose", window.top.document).length == 0) { //附加遮罩層dom $("body", window.top.document).append("<div class=‘showmaskclose‘>×</div>").append("<div class=‘showmask‘></div>").append("<div class=‘showmasklayer‘></div>") //附加後綁定事件 $(".showmaskclose", window.top.document).on("click", function () { htsHide(); }) $(".showmask", window.top.document).on("dblclick", function () { htsHide(); }) $(".showmasklayer", window.top.document).on("dblclick", function () { htsHide(); }) //添加圖片 $(".showmasklayer", window.top.document).append("<img src=‘" + this.src + "‘ />") } else { //遮罩層dom顯示 $(".showmaskclose", window.top.document).show(); $(".showmask", window.top.document).show(); $(".showmasklayer", window.top.document).show(); //切換圖片 $(".showmasklayer > img", window.top.document).attr(‘src‘, this.src); } }); }); function htsHide() { //遮罩層隱藏 $(".showmask", window.top.document).hide(); $(".showmaskclose", window.top.document).hide(); $(".showmasklayer", window.top.document).hide(); }
jquery 遮罩層顯示img