Inpage Popup are most used JS for website developers. Here in this article I given full detailed code for popup using javascript. Many times we need to minimize and restore functionality for our in page pop-up. In This article I will show how to achieve the minimize and maximize and restore functionality with javascript.
minimize, restore, maximize and hide functionality with javascript
I you want the minimize functionality for your in page pop-up use following code for minimize and restore button. Following code you can use for showing the minimize button on pop-up.
Note: Here for this example My in page popup div id name is “popup-container”. For using following example you should keep the main popup continer id name is “popup-container”.
<a id="dialog-minimize" href="#" onclick="minimize();" style="display: block;"><span>Min</span></a> <a id="dialog-minimize-return" href="#" onclick="minimize_restore();" style="display:none;"><span>Min</span></a>
Use following javascript function in your document.
[viral-lock message=”Solution code is Hidden! It’s Visible for Users who Liked/Shared This article on Facebook or Twitter or Google+. Like or Tweet this article to reveal the content.”]
function minimize(){ var main-containter = document.getElementById('popup-container'); window.divh = main-containter.style.height; window.divw = main-containter.style.width; window.divtop = main-containter.style.top; window.divleft = main-containter.style.left; var hideminbutton = document.getElementById('dialog-minimize'); hideminbutton.style.display = "none"; var hideminbutton = document.getElementById('dialog-minimize-return'); hideminbutton.style.display = "block"; main-containter.style.position ="absolute"; main-containter.style.left ="10px"; main-containter.style.bottom ="0px"; main-containter.style.marginBottom ="-100px"; main-containter.style.top = "auto"; /* css({position:"absolute", left:"10px", width: 250, height: 100, bottom:"-60px"}); top: 389px; left: 381px; bottom: -60px; */ } function minimize_restore(){ var popup_element = document.getElementById('popup-container'); popup_element.style.position ="absolute"; popup_element.style.height = window.div_height; popup_element.style.width = window.div_width; popup_element.style.left = window.divleft; popup_element.style.top = window.divtop; var hideminbutton = document.getElementById('dialog-minimize'); hideminbutton.style.display = "block"; var hideminbutton = document.getElementById('dialog-minimize-return'); hideminbutton.style.display = "none"; }
Above function will swap the minimize and restore button through javascript.
Using following function you can achieve the maximize and maximize restore functionality using the simple javascript. following code you need to use in your html for maximize button.
<a id="dialog-maximize" onclick="maximize();" href="#" style="display: block;"><span>Max</span></a> <a id="dialog-maximize-return" onclick="maximize_restore();" href="#" style="display: none;"><span>Max</span></a>
following javascript code you need to use in your document.
function maximize_restore(){ var popup_element = document.getElementById('popup-container'); popup_element.style.position ="absolute"; popup_element.style.left = window.divleft; popup_element.style.top = window.divtop; popup_element.style.height = window.div_height; popup_element.style.width = window.div_width; var hideminbutton = document.getElementById('dialog-maximize'); hideminbutton.style.display = "block"; var hideminbutton = document.getElementById('dialog-maximize-return'); hideminbutton.style.display = "none"; } function maximize(){ var popup_element = document.getElementById('popup-container'); window.div_height = popup_element.style.height; window.div_width = popup_element.style.width; window.divtop = popup_element.style.top; window.divleft = popup_element.style.left; var hideminbutton = document.getElementById('dialog-maximize'); hideminbutton.style.display = "none"; var hideminbutton = document.getElementById('dialog-maximize-return'); hideminbutton.style.display = "block"; var myWidth = 0, myHeight = 0; if( typeof( window.innerWidth ) == 'number' ) { //Non-IE myWidth = window.innerWidth; myHeight = window.innerHeight; } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode' myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight; } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible myWidth = document.body.clientWidth; myHeight = document.body.clientHeight; } myWidth = myWidth -25; myHeight = myHeight -20; var popup_element = document.getElementById('popup-container'); popup_element.style.position ="absolute"; popup_element.style.left ="10px"; popup_element.style.height = myHeight +"px"; popup_element.style.width = myWidth +"px"; popup_element.style.top = "5px"; }
[/viral-lock]
If you having any issue with this script please get back to me. Please write email to me on support@purabtech.in
If you need the more information about Javascript and Jquery then please refer the following articles.
wordpress and jquery conflicts – How to solve that
100+ jquery and CSS techniques and Tips and tutorials
jquery tips for wordpress theme developers
Fadein and Fadeout effect through javascript
minimize, restore, maximize and hide functionality with javascript without using jquery
Complete Javascript form Validation now easy ( Checkbox, Websites, Email, Maxlength)