Simple jQuery Plugin For Opening A Popup Window On Page load

File Size: 5.19 KB
Views Total: 295343
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
Simple jQuery Plugin For Opening A Popup Window On Page load

A tiny and easy jQuery plugin that automatically opens a dialog pop-up with cool transition effect when the web page loads.

How to use it:

1. Create the content for your popup.

<div id="boxes">
  <div id="dialog" class="window">
    Your Content Goes Here
    <div id="popupfoot"> <a href="#" class="close agree">I agree</a> | <a class="agree"style="color:red;" href="#">I do not agree</a> </div>
  <div id="mask"></div>

2. The sample CSS to style the popup window.

#mask {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 9000;
  background-color: #000;
  display: none;

#boxes .window {
  position: absolute;
  left: 0;
  top: 0;
  width: 440px;
  height: 200px;
  display: none;
  z-index: 9999;
  padding: 20px;
  border-radius: 15px;
  text-align: center;

#boxes #dialog {
  width: 750px;
  height: 300px;
  padding: 10px;
  background-color: #ffffff;
  font-family: 'Segoe UI Light', sans-serif;
  font-size: 15pt;

#popupfoot {
  font-size: 16pt;
  position: absolute;
  bottom: 0px;
  width: 250px;
  left: 250px;

3. Include the necessary jQuery library at the bottom of the web page.

<script src="//"></script> 

4. The Javascript to open the popup window on document ready.

$(document).ready(function() {	

var id = '#dialog';
//Get the screen height and width
var maskHeight = $(document).height();
var maskWidth = $(window).width();
//Set heigth and width to mask to fill up the whole screen

//transition effect
//Get the window height and width
var winH = $(window).height();
var winW = $(window).width();
//Set the popup window to center
$(id).css('top',  winH/2-$(id).height()/2);
$(id).css('left', winW/2-$(id).width()/2);
//transition effect
//if close button is clicked
$('.window .close').click(function (e) {
//Cancel the link behavior


//if mask is clicked
$('#mask').click(function () {

This awesome jQuery plugin is developed by fleroviums. For more Advanced Usages, please check the demo page or visit the official website.