Setup SimpleModal jQuery Popup, Close Popup When Clicking Outside of Popup

7/23/2014 3:51:03 AM

This uses the simplemodal jQuery popup library. It will center the popup horizontally and place the top at 50px; It will also close the popup when clicking outside of the popup

 

http://www.ericmmartin.com/projects/simplemodal/

http://jquery.com/download/

<script type="text/javascript">
	//close the popup when clicking outside of the popup
	$.modal.defaults.overlayClose = true;	
	
	//center the popup horizontally and place at 50px from top vertically
	$.modal.defaults.position = [50, ];
		
	function showPopup()
	{	    	    
	    $('#divPopup').modal();
	}

</script>

<style>
    #basic-modal-content {display:none;}

    /* Overlay */
    #simplemodal-overlay {background-color:#000;}

    /* Container */
    #simplemodal-container {height:360px; width:600px; color:#bbb; background-color:#333; border:4px solid #444; padding:12px;}
    #simplemodal-container .simplemodal-data {padding:8px;}
    #simplemodal-container code {background:#141414; border-left:3px solid #65B43D; color:#bbb; display:block; font-size:12px; margin-bottom:12px; padding:4px 6px 6px;}
    #simplemodal-container a {color:#ddd;}
    #simplemodal-container a.modalCloseImg {background:url(../img/basic/x.png) no-repeat; width:25px; height:29px; display:inline; z-index:3200; position:absolute; top:-15px; right:-16px; cursor:pointer;}
    #simplemodal-container h3 {color:#84b8d9;}
</style>

<button onclick="showPopup();">Show Popup</button>

<div id="divPopup" style="display: none; ">
    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt
    ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
    laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in
    voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat
    non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>