Today I am going to demonstrate a stunning popup window control for web developers. I thought there were plenty of such controls available on the internet but still I need to create my own as I need to develop such controls with little efforts.
This popup control is extremely easy to implement, all you need to do is include the jQuery libraries (1, 2, 3 )and our jQuery Popup library file braviPopUp.js at the top of your HTML page, as well as a small amount of jQuery code.
This Popup control is a floating window that contains a title bar and a content area for the popup page to be shown in the dialog. The dialog window can be moved, resized and closed with the 'x' icon by default.
If the content length exceeds the maximum height, a scrollbar will automatically appear.You can set width and height of the control. There is a limit for minimum width and height.
braviPopUp method defined in the braviPopUp.js takes four perameters
- title of the page
- source URL
To show the popup page content there is a Iframe inside the floating div that is used to show the popup control. This div is appended in the Bodyof the page with some css settings so that it can be centered.
Using the code
Method defined in the braviPopUp.js is named braviPopUp and it takes four arguments title, url, width, height. I created raw html containg the main div with the title bar, close button, content area iFrame. When call the braviPopUp method it will append this html into page body with some css setting to center the control in the web page.
the jQuery code:
Control's close method:
To call the close method from the poup page use parent.CloseDialog();
Here I am removing the HTML so that it will be completely destroy.
After all magic of appending the control to page body css is very important part of this control. positions and looks of all div, span are managed by css. Also there are few images like the title bar image, close button icon etc
Using jQuery ready method I register the button click event and call the popup window.
This is an idea from my early post jQuery alert control. Now it has become a popup window control.