<?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>WebDesign &#38; Such &#187; Pop Up</title>
	<atom:link href="http://webdesignandsuch.com/tag/pop-up/feed/" rel="self" type="application/rss+xml" />
	<link>http://webdesignandsuch.com</link>
	<description>a Beantown Design Production</description>
	<lastBuildDate>Thu, 29 Jul 2010 00:02:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to create a Popup with CSS and Javascript</title>
		<link>http://webdesignandsuch.com/2009/12/how-to-create-a-popup-with-css-and-javascript/</link>
		<comments>http://webdesignandsuch.com/2009/12/how-to-create-a-popup-with-css-and-javascript/#comments</comments>
		<pubDate>Sat, 26 Dec 2009 17:27:23 +0000</pubDate>
		<dc:creator>ilz</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[Downloads]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Pop Up]]></category>
		<category><![CDATA[Popup]]></category>

		<guid isPermaLink="false">http://webdesignandsuch.com/?p=709</guid>
		<description><![CDATA[
			
				
			
		

Popups suck.
The good thing is you don&#8217;t see that many of them any more. That&#8217;s because browsers recognize that they suck and are most likely spam or ads and so they block the popups. The old way of creating a popup was to force open a new browser window over the current browser window. So [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px; margin-bottom:10px">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwebdesignandsuch.com%2F2009%2F12%2Fhow-to-create-a-popup-with-css-and-javascript%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=?url=http%3A%2F%2Fwebdesignandsuch.com%2F2009%2F12%2Fhow-to-create-a-popup-with-css-and-javascript%2F&amp;style=normal" height="61" width="51" /><br />
			</a>
		</div>
<p><img class="alignnone" style="border: 3px solid #000; margin: 0 0 15px 0;" title="css popup" src="http://webdesignandsuch.com/posts/css-popup/pop.gif" alt="" width="422" height="211" /></p>
<h2 style="margin-bottom:20px">Popups suck.</h2>
<p>The good thing is you don&#8217;t see that many of them any more. That&#8217;s because browsers recognize that they suck and are most likely spam or ads and so they block the popups. The old way of creating a popup was to force open a new browser window over the current browser window. So this is what browsers block. But what if you actually have a need to use a popup window for something useful and not spammy? This happened to me the other day. A client wanted a popup window on their homepage to wish everyone a Merry Christmas.</p>
<p>Knowing I couldn&#8217;t use the old popup method, I went searching. I knew it&#8217;d be easy enough to use CSS to put a floating div over the content of the site, which creates a popup effect. The problem was how do you close the popup once it&#8217;s open? Javascript would be needed for this. Check out the demo I setup which shows how the <strong>CSS popup</strong> can be set to open on <strong>pageload</strong> or by <strong>clicking on a link</strong>; and then how Javascript allows you to have a &#8220;close&#8221; button that shuts or hides the popup. Then continue reading for the code and downloadable files.</p>
<p><a class="demo-link" href="http://webdesignandsuch.com/posts/css-popup/css-popup.html">View Demo</a></p>
<p><span id="more-709"></span></p>
<p>If you check out the source code of the html file, you&#8217;ll see the following in the body. The &#8220;<strong>blanket</strong>&#8221; is the effect of putting the transparent black background behind the popup, which helps separate it from the rest of the content on the page. The &#8220;<strong>popUpDiv</strong>&#8221; is where you put the content of your popup.</p>
<div class="codeBox">&lt;div id=&#8221;blanket&#8221; style=&#8221;display:none;&#8221;&gt;&lt;/div&gt;<br />
&lt;div id=&#8221;popUpDiv&#8221; style=&#8221;display:none;&#8221;&gt;</p>
<p>&lt;a href=&#8221;#&#8221; onclick=&#8221;popup(&#8216;popUpDiv&#8217;)&#8221; &gt;Click to Close CSS Pop Up&lt;/a&gt;<br />
&lt;/div&gt;<br />
&lt;a href=&#8221;#&#8221; onclick=&#8221;popup(&#8216;popUpDiv&#8217;)&#8221;&gt;Click to Open CSS Pop Up&lt;/a&gt;</p>
</div>
<p>If you want the popup to load on <strong>page load</strong>, put the following in your body tag.</p>
<div class="codeBox">&lt;body   onload=&#8221;popup(&#8216;popUpDiv&#8217;)&#8221;&gt;</div>
<p>Here is the CSS used to style the blanket effect and the popup div. You&#8217;ll see I turned the blanket effect off for Internet Explorer, since it doesn&#8217;t appear to support &#8220;opacity&#8221; (big surprise).</p>
<div class="codeBox">#blanket {<br />
background-color:#111;<br />
opacity: 0.65;<br />
*background:none;<br />
position:absolute;<br />
z-index: 9001;<br />
top:0px;<br />
left:0px;<br />
width:100%;<br />
}</p>
<p>#popUpDiv {<br />
position:absolute;<br />
background:url(pop-back.jpg) no-repeat;<br />
width:400px;<br />
height:400px;<br />
border:5px solid #000;<br />
z-index: 9002;<br />
}</p>
</div>
<p>There is a Javacript file linked to the html file to make some of the magic happen. I&#8217;m going to make the demo files available so you can play with it and make your own. <strong>Enjoy!</strong></p>
<p><a class="demo-link" href="http://webdesignandsuch.com/posts/css-popup/css-popup.zip">Download Files</a></p>
<p>One last thing.. the original code for this was <a href="http://www.pat-burt.com/web-development/how-to-do-a-css-popup-without-opening-a-new-window/">found here</a>. I made some edits to make it work for my application.</p>
]]></content:encoded>
			<wfw:commentRss>http://webdesignandsuch.com/2009/12/how-to-create-a-popup-with-css-and-javascript/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
