Home >Web Front-end >JS Tutorial >iframe extension code for jquery.boxy plug-in_jquery

iframe extension code for jquery.boxy plug-in_jquery

WBOY
WBOYOriginal
2016-05-16 18:23:59782browse
Copy code The code is as follows:

/*


Boxy attributes remain unchanged and new w, h, src attributes are added
qBox.Close(); Close the current window
qBox.iFSrc({}); Change the attributes of the current window and point to the Boxy attribute unchanged. Add w, h, src attributes
*/

//Extension of the Boxy plug-in
jQuery .fn.qbox=function(options){
var node = this.get(0).nodeName.toLowerCase();
var self=this;
if (node ​​== 'a') {
$(this).attr('onclick','').unbind('click').click(function(){return false;});
options = $.extend(options||{ },{src:this.get(0).getAttribute('href'),beforeUnload:function(){ $(self).unbind('click').click(function(){return $(this).qbox (options);});}});
}
qBox.iFLoad(options);
return false;
}
var qBox=function(){};
jQuery.extend(qBox,{
aDgs:[],
iFrame:function(op){
op = jQuery.extend({title:'Prompt',w:320,h:200,src :'about:blank',modal:false,fixed:false,unloadOnHide:true},op),fm=parseInt(Math.random()*(1000*987));//
var dialog = new Boxy ("Loading, please wait....",op);

jQuery("# _" fm).load(function(){
dialog.resize(op.w,op.h,function(){});
jQuery("#ld" fm).remove();
jQuery("#_" fm).css({'padding':'15px','display':''});
});
qBox.aDgs.push(dialog);
return false;
},
Close:function(){
qBox.aDgs[qBox.aDgs.length-1].hide();
return false
},
iFSrc:function(op){
op = jQuery.extend({w:320,h:200,src:'about:blank'},op);
qBox.aDgs[qBox.aDgs. length-1].getContent().attr("src","about:blank");
qBox.aDgs[qBox.aDgs.length-1].setTitle(op.t);
qBox. aDgs[qBox.aDgs.length-1].tween(op.w,op.h,function(){qBox.aDgs[qBox.aDgs.length-1].getContent().attr("src",op. src).css({width:op.w,height:op.h});});
return false;
},
iFLoad:function(options){
var sr= jQuery(this).attr("href");
var op = jQuery.extend({src:sr},options);
qBox.iFrame(op);
return false;
}
});


Source cn795.cnblogs.com