I have written some articles before using the Boxy pop-up box (view jquery. (boxy basis). Today, after solving a need, I think it is worthwhile to record it, so I will write another article. The main function is that after the pop-up dialog box, automatically hide every N seconds, and some articles have been written before the use of the Boxy pop-up box (view jquery. (boxy basis). Today, after solving a need, I think it is worthwhile to record it, so I will write another article. The main function is that after the pop-up dialog box, automatically hide every N seconds, and automatically Jump!
Effect:
The encapsulated code is as follows::
The Code is as follows:
// Boxy dialog box Extension
Var Boxy_Extensions = {
Options :{
Title: 'yiba hint ',
CloseText: 'X'
},
// Hide it N seconds after the pop-up
AlertDelayFun: function (info, timer, options ){
Options = $. extend (this. options, options || {});
New Boxy ("
"+ Info +"
", $. Extend ({behaviours: function (){
SetTimeout ('$ (". boxy-wrapper"). hide ();', timer );
}
}, Options ));
},
// Jump automatically after the pop-up
AlertHrefFun: function (info, href, options ){
Options = $. extend (this. options, options || {});
New Boxy ("
"+ Info +"
", $. Extend ({behaviours: function (){
Location. href = href;
}
}, Options ));
}
}
Because the options attribute is public, it is mentioned, and each method has its own options. If you pass options when calling your own method, $. extend will
Merge with the content of the options attribute in the class (overwrite the key value and extend the new key value). It seems that JS writing should also follow the object-oriented principle!