Modify the dialog box plug-in jquery as a framework page (iframe)

Source: Internet
Author: User

Jquery has a very good ui plug-in, dialog plug-in, his official website has a variety of forms of Demonstration: http://jqueryui.com/demos/dialog/, it may be a lot of home or its default mode, I will not repeat the specific usage on the official website, but also the Chinese explanation address. I recently posted a framework page, taking a closer look, similar to the modal form mode of dialog plug-in, demo effect: http://www.lovewebgames.com/addNews.aspx

This is the effect. The login registration pop-up layer is required. Why don't I use modal form directly? Because I like it, you care about me. So I made a dialog plug-in under jquery, and I need to reference the original dialog file. The Code is as follows:

Copy codeThe Code is as follows: (function ($ ){
$. Fn. openWidow = function (options ){
Var divId = "dialog" + Math. round (Math. random () * 100 );
Var settings = {
Id: divId,
Width: 300,
Height: 200,
Modal: true,
Buttons :{
},
Show: "explode ",
Hide: "highlight ",
Title: "prompt ",
Url: "/test. aspx ",
Close: function (){
$ ("#" + This. id). remove ();
// Debugger
If (document. getElementById (this. id ))
Document. body. removeChild (document. getElementById (this. id ));
}
};
If (options ){
$. Extend (settings, options );
}
$ ("Body "). append ('<div id = "' + settings. id + '"title =" Dialog Title "> <p class =" loading "> </p> </div> ');
// Dialog
$ ('#' + Settings. id). dialog ({
AutoOpen: false,
Title: settings. title,
Width: settings. width,
Height: settings. height,
Modal: true,
Bgiframe: true,
Show: settings. show,
Hide: settings. hide,
Buttons: settings. buttons,
Close: settings. close,
Open: function (){
$ ("#" + Settings.id).html ('<iframe src = "' + settings. url + '"frameborder =" 0 "height =" 100% "width =" 100% "id =" dialogFrame "scrolling =" auto "> </iframe> ');
},
ResizeStop: function (){
$ ("# DialogFrame" ).css ("width", parseint((this).css ("width")-5 );
$ ("# DialogFrame" ).css ("height", parseint((this).css ("height")-5 );
}
});

$ ('#' + Settings. id). dialog ("open ");
Return this;
};
}) (JQuery );

I think everyone should still understand it. Nothing complicated is to repeat and repeat the work. Even many parameters are dialog. I just added a layer. I believe that this method is intended for many new users. After all, not everyone enjoys and is familiar with ajax. At this time, iframe is very useful.

I also hope that interested friends can join my Q groups: 70210212 and 5678537. I usually check them out and don't have to worry about any problems.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.