Css:
<style>
/* Public pop-up layer */
. 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" > Add </button>
<div id= "popup" style= "Display:none;"
<div class= "poploading" > Loading ... </div>
<button id= "btn Open "> </button>
<button id=" Btncancle "> Cancel </button>
</div>
<div class=" Popup1 "style=" Display:none; "
<button id= "BtnOpen1" > Open 1</button>
</div>
& Lt;iframe src= "" frameborder= "0" scrolling= "0" id= "iframe" style= "Display:none;" ></iframe>
<script>
$ (function () {
$ (". Add"). Click (function () {
$ ("#popup"). Popshow ({
URL: "",
Title: "Edit",
width:800,
height:700
});
});
$ ("#btnOpen"). Delegate ("", "click", Function () {
$ (". Popup1"). Popshow ({
URL: "",
Title: "Edit 111111",
width:600,
height:500
});
});
$ ("#btnOpen1"). Delegate ("", "click", Function () {
$ ("#iframe"). Popshow ({
URL: "Https://www.baidu.com",
Title: "Detail Page"
});
});
});
</script>
The following is the plugin content:
(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& Gt;</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;
});
};
Close the pop-up window
$.fn.pophide = function () {
var tab = $ (this). Closest ('. Popwrap ');
$ (this). Hide (). AppendTo (' body ');
Tab.remove ();
return this;
};
}) (JQuery);
jquery Expansion plugin-popup pop-up window