<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>A K Chauhan's Blog &#187; Modal Window</title>
	<atom:link href="http://www.akchauhan.com/tag/modal-window/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.akchauhan.com</link>
	<description>PHP, MySql, JavaScript, JQuery, Prototype, Drupal, HTML, CSS and more...</description>
	<lastBuildDate>Sun, 04 Jul 2010 20:19:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>A Simple Modal Window Using CSS And JQuery</title>
		<link>http://www.akchauhan.com/a-simple-modal-window-using-css-and-jquery/</link>
		<comments>http://www.akchauhan.com/a-simple-modal-window-using-css-and-jquery/#comments</comments>
		<pubDate>Sun, 24 May 2009 16:16:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Modal Window]]></category>
		<category><![CDATA[Thickbox]]></category>

		<guid isPermaLink="false">http://www.akchauhan.com/?p=279</guid>
		<description><![CDATA[In this tutorial, I&#8217;m going to share how to create a simple attractive light weight modal window with jQuery and CSS. I like jQuery, because it makes everything so simple and so easy. You can view the working demo here. Right, let&#8217;s start, this example will show you how to create a modal window that [...]]]></description>
			<content:encoded><![CDATA[<p><div id="attachment_420" class="wp-caption aligncenter" style="width: 480px"><img src="http://www.akchauhan.com/wp-content/uploads/2009/05/popup.jpg" alt="Simple Modal Window Using CSS and jQuery" title="Simple Modal Window Using CSS and jQuery" width="470" height="302" class="size-full wp-image-420" /><p class="wp-caption-text">Simple Modal Window Using CSS and jQuery</p></div><br />
In this tutorial, I&#8217;m going to share how to create a simple attractive light weight modal window with jQuery and CSS. I like jQuery, because it makes everything so simple and so easy.  <br/><br />
<strong><em>You can view the working demo <a title="View demo" href="http://www.akchauhan.com/examples/example10/" target="_blank">here</a>.</em></strong><br/><br />
Right, let&#8217;s start, this example will show you how to create a modal window that will display the content of a DIV using its #ID.<br/><br />
For jQuery,  please include jQuery file in your page where you want to use this model window.</p>
<p><strong>1. HTML code </strong></p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"># <span style="color: #808080; font-style: italic;">&lt;!-- #dialog is the id of a DIV defined in the code below --&gt;</span>
# <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;modalwindow&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#open&quot;</span>&gt;</span>Open<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
#
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
#
#     <span style="color: #808080; font-style: italic;">&lt;!--You easily customize your window here --&gt;</span>
#
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;window&quot;</span>&gt;</span>
#         <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">strong</span>&gt;</span>Testing of Modal Window<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">strong</span>&gt;</span> |
#
#         <span style="color: #808080; font-style: italic;">&lt;!-- close button is defined as close window --&gt;</span>
#         <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;close&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Close window<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
#
#<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
#
#     <span style="color: #808080; font-style: italic;">&lt;!-- Do not remove div#hide, because you shall need it to fill the whole screen --&gt;</span>
#
#<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>

<p><strong>2. CSS code</strong></p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">&nbsp;
# /* Z-index of #hide must lower than #container .window */
# #hide {
#   position:absolute;
#   z-index:9000;
#   background-color:#000;
#   display:none;
# }
#
# #container .window {
#   position:absolute;
#   width:440px;
#   height:200px;
#   display:none;
#   z-index:9999;
#   padding:20px;
# }
#
#
# /* Customize your modal window here, you can add background image too */
# #container #openbox {
#   width:375px;
#   height:203px;
# }</pre></div></div>

<p><strong>3. Jquery code</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"># $<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
#
#     <span style="color: #006600; font-style: italic;">//select all the a tag with name equal to modalwindow</span>
#     $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a[name=modalwindow]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
#         <span style="color: #006600; font-style: italic;">//Cancel the link behavior</span>
#         e.<span style="color: #660066;">preventDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
#         <span style="color: #006600; font-style: italic;">//Get the A tag</span>
#         <span style="color: #003366; font-weight: bold;">var</span> id <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
#
#         <span style="color: #006600; font-style: italic;">//Get the screen height and width</span>
#         <span style="color: #003366; font-weight: bold;">var</span> hideHeight <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">height</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
#         <span style="color: #003366; font-weight: bold;">var</span> hideWidth <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
#
#         <span style="color: #006600; font-style: italic;">//Set heigth and width to hide to fill up the whole screen</span>
#         $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#hide'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'width'</span><span style="color: #339933;">:</span>hideWidth<span style="color: #339933;">,</span><span style="color: #3366CC;">'height'</span><span style="color: #339933;">:</span>hideHeight<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
#
#         <span style="color: #006600; font-style: italic;">//transition effect</span>
#         $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#hide'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
#         $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#hide'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeTo</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;slow&quot;</span><span style="color: #339933;">,</span><span style="color: #CC0000;">0.8</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
#
#         <span style="color: #006600; font-style: italic;">//Get the window height and width</span>
#         <span style="color: #003366; font-weight: bold;">var</span> winH <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">height</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
#         <span style="color: #003366; font-weight: bold;">var</span> winW <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
#
#         <span style="color: #006600; font-style: italic;">//Set the popup window to center</span>
#         $<span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'top'</span><span style="color: #339933;">,</span>  winH<span style="color: #339933;">/</span><span style="color: #CC0000;">2</span><span style="color: #339933;">-</span>$<span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">height</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
#         $<span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'left'</span><span style="color: #339933;">,</span> winW<span style="color: #339933;">/</span><span style="color: #CC0000;">2</span><span style="color: #339933;">-</span>$<span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
#
#         <span style="color: #006600; font-style: italic;">//transition effect</span>
#         $<span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">2000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
#
#     <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
#
#     <span style="color: #006600; font-style: italic;">//if close button is clicked</span>
#     $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.window .close'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
#         <span style="color: #006600; font-style: italic;">//Cancel the link behavior</span>
#         e.<span style="color: #660066;">preventDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
#         $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#hide, .window'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
#     <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
#
#     <span style="color: #006600; font-style: italic;">//if hide is clicked</span>
#     $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#hide'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
#         $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
#         $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.window'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
#     <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
#
# <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
#</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.akchauhan.com/a-simple-modal-window-using-css-and-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
