jquery拓展外掛程式-popup彈窗

來源:互聯網
上載者:User

標籤:mask   pre   pointer   tab   size   ret   dex   family   ndt   

css:
<style>
/* 公用彈出層 */
.popWrap{position: fixed;left: 0;top: 0; width: 100%;height: 100%;z-index: 1000000;}
.popMask{width:100%;height:100%;background-color:#ddd;filter:Alpha(opacity=50);-moz-opacity:0.5;opacity:0.5; }
.popMask iframe,.popMain .popCont iframe{ width: 100%;height: 100%;border: 0 none; }
.popMain{ position: absolute;left: 50%;top: 50%;background-color: #fff;z-index: 1000001; border: 1px solid #2d2d2d;}
.popMain .popTit { background-color: #2d2d2d;color: #fff;font-size: 12px;height: 28px;line-height: 28px;padding-left: 12px;padding-right: 12px;}
.popMain .popTit .close{ font-family: iconfont; font-size: 12px;cursor: pointer;color: #fff; }
.popMain .popTit .close:hover{ color: #fff; }
.popMain .popCont {}
.popMain .popCont .popLoading { margin: 10px ;}
</style>

html:

<button id="btnAdd" class="add">添加</button>
<div id="popup" style="display: none;">
<div class="popLoading">載入中...</div>
<h1>welcome</h1>
<button id="btnOpen">開啟</button>
<button id="btnCancle">取消</button>
</div>
<div class="popup1" style="display: none;">
<h1>hello world</h1>
<button id="btnOpen1">開啟1</button>
</div>
<iframe src="" frameborder="0" scrolling="0" id="iframe" style="display: none;"></iframe>

<script>
$(function(){

$(".add").click(function(){
$("#popup").popShow({
url : "",
title : "編輯",
width : 800,
height: 700
});
});

$("#btnOpen").delegate("","click",function(){
$(".popup1").popShow({
url : "",
title : "編輯111111",
width : 600,
height: 500
});
});

$("#btnOpen1").delegate("","click",function(){
$("#iframe").popShow({
url : "https://www.baidu.com",
title : "詳情頁"
});
});


});
</script>
以下為外掛程式內容:

(function($){

$.fn.popShow = function (opitons) {
var defaults = {
url: "",
title: "",
width: "800",
height: "600"
};
var settings = $.extend({}, defaults, opitons);
this.each(function () {
var tac = $(this),
url = settings.url,
title = settings.title,
width = settings.width,
height = settings.height;
var tag = $(‘<div class="popWrap"><div class="popMask" ><iframe scrolling="no"src="about:blank"></iframe></div><div class="popMain" style="width: ‘ + width + ‘px;height: ‘ + height + ‘px;margin-left:-‘ + width / 2 + ‘px;margin-top:-‘ + height / 2 + ‘px"><div class="popTit"><a class="close fr">&#xe606;</a><span>‘ + (title ? title : ‘‘) + ‘</span></div><div class="popCont"></div></div></div>‘).appendTo("body");

tag.find(".close").click(function () {
tac.popHide();
});
tag.find(".popCont").append($(this).show());
if ($.trim(url).length != 0) {
tac.prop("src", url);
}
return this;
});
};
//關閉彈窗
$.fn.popHide = function () {
var tab = $(this).closest(‘.popWrap‘);
$(this).hide().appendTo(‘body‘);
tab.remove();
return this;
};

})(jQuery);

jquery拓展外掛程式-popup彈窗

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.