<?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>The Infinite Loop - Beginner&#039;s SEO, Beginner C# &#38; JQuery Tutorials &#187; Javascript</title>
	<atom:link href="http://theinfiniteloopblog.com/category/programming/jscript/feed/" rel="self" type="application/rss+xml" />
	<link>http://theinfiniteloopblog.com</link>
	<description>Problem. Problem Solved. Loop. - The life of a programmer</description>
	<lastBuildDate>Wed, 17 Aug 2011 15:29:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Google SEO Flash &amp; Flash Tips/Techniques</title>
		<link>http://theinfiniteloopblog.com/programming/jscript/google-seo-flash-flash-tipstechniques/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=google-seo-flash-flash-tipstechniques</link>
		<comments>http://theinfiniteloopblog.com/programming/jscript/google-seo-flash-flash-tipstechniques/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 08:38:08 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[SEO/Marketing]]></category>
		<category><![CDATA[XHTML/CSS]]></category>
		<category><![CDATA[flash seo techniques]]></category>
		<category><![CDATA[flash seo tips]]></category>
		<category><![CDATA[google seo flash]]></category>
		<category><![CDATA[google seo flash tips]]></category>
		<category><![CDATA[how to seo flash]]></category>
		<category><![CDATA[seo flash]]></category>

		<guid isPermaLink="false">http://theinfiniteloopblog.com/?p=285</guid>
		<description><![CDATA[Google SEO Flash Google currently DOES index flash, however, I believe it is extremely unreliable. Clients have asked me to do some SEO work on their sites, little did I know, these sites were flash! Most crawlers seem to have a hard time crawling flash and the #1 tip I can give for Flash SEO [...]]]></description>
			<content:encoded><![CDATA[
<!-- ALL ADSENSE ADS DISABLED -->
<h2>Google SEO Flash</h2>
<p>Google currently DOES index flash, however, I believe it is extremely unreliable. Clients have asked me to do some SEO work on their sites, little did I know, these sites were flash!</p>
<p>Most crawlers seem to have a hard time crawling flash and the #1 tip I can give for Flash SEO is: don't show search engine crawlers flash, show them alternate content!</p>
<p>The reasoning behind this technique:<br />
1) Underlying HTML Content<br />
2) Use javascript to load Flash<br />
3) GoogleBot = No Javascript = Doesn't see flash, sees alternate content</p>
<p>For two of the sites I have worked on, I have used JQuery, JQuery SWFObject Plugin, and a base HTML site to get these sites indexed. Search engine crawlers do not have javascript,  so we will use it to load our flash. If our client has flash and javascript, our client will see Flash. If they dont (Googlebot doesn't have Javascript) they will see our underlying HTML content. Let's take a look at this code:</p>
<p>&lt;div id="flash"&gt;&lt;/div&gt;<br />
&lt;div id="altContent"&gt;<br />
&lt;h1&gt;<strong>Google SEO Flash Tips and Techniques</strong>&lt;/h1&gt;<br />
&lt;h2&gt;<strong>How To SEO Flash for Google</strong>&lt;/h2&gt;<br />
&lt;/div&gt;<br />
On your main page, write &lt;div id="flash"&gt;&lt;/div&gt;, then wrap your Search Engine Optimized code in &lt;div id="altContent"&gt;&lt;/div&gt;.</p>
<p>As you can see, the content in the "altContent" div, is pure html which we can apply the following <a href="http://theinfiniteloopblog.com/?p=19">Basic SEO Techniques </a>to. We have an empty div above with the id "flash". We will use JQuery &amp; the SWFObject to load our flash file into our "flash" div. Since the flash loading is done using javascript, Search Engine Crawlers will not see the flash, but will see our optimized HTML content.</p>
<p>Download a copy of JQuery here:<a href="http://docs.jquery.com/Downloading_jQuery"> http://docs.jquery.com/Downloading_jQuery<br />
</a>and SWFObject plugin here: <a href="http://jquery.thewikies.com/swfobject/downloads"> http://jquery.thewikies.com/swfobject/downloads</a><br />
We will put all our files in the same directory for simplicity, you can put them in a seperate 'scripts' directory if you want to keep organized.</p>
<p>On our main page, we will add the script references (order is important! first load jquery, then the swfobject plugin):&lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt;<br />
&lt;script type="text/javascript" src="jquery.swfobject.js"&gt;&lt;/script&gt;</p>
<p>Now, underneath this, we will add the function to load our flash file:</p>
<ol>
<li>&lt;script&gt;</li>
<li> $("document").ready(function(){</li>
<li> if($.flash.available){</li>
<li> $("#flash").flash({</li>
<li> swf: 'main_flash8.swf',</li>
<li> width:766,</li>
<li> height:750</li>
<li> });</li>
<li> $("#altContent").css("display", "none");</li>
<li> }</li>
<li>});</li>
<li>&lt;/script&gt;</li>
</ol>
<p>This code should be pretty self explanatory, but, let me explain:<br />
Line 2: We are setting up a function to run when our document has been loaded.<br />
Line 3:Check that the user has the flash plugin and it is enabled<br />
Line 4: We are using the .flash() method of SWFObject to load content into the #flash div. (# stands for id  . stands for class)<br />
Line 5: We set the swf: parameter to our swf file<br />
Line 6/7: We set the width/height<br />
Line 9: Now that our flash has loaded, we set the display of the altContent div to none, which will hide it.</p>
<p>Since GoogleBot does not have javascript, the code to load the flash and hide the altContent will never run.<br />
If a user has flash, the flash site will load. If not, they will see the html content.</p>
<p>Searching for my clients business name, they could not be found anywhere. Once I applied the technique above, they were #1 within a week (Search engines do take some time <img src='http://theinfiniteloopblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> )</p>
<p>This technique is widely accepted. For some more reading, check out: <a title="Yes, Google Does Index Flash" href="http://www.yourseoplan.com/google-flash/" target="_blank">Google Does Index Flash</a></p>
<p>Hope this article helps.<br />
Comment if it did!</p>
]]></content:encoded>
			<wfw:commentRss>http://theinfiniteloopblog.com/programming/jscript/google-seo-flash-flash-tipstechniques/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Professional Table Styling using CSS</title>
		<link>http://theinfiniteloopblog.com/programming/professional-table-styling-using-css/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=professional-table-styling-using-css</link>
		<comments>http://theinfiniteloopblog.com/programming/professional-table-styling-using-css/#comments</comments>
		<pubDate>Sun, 20 Sep 2009 02:20:30 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[XHTML/CSS]]></category>

		<guid isPermaLink="false">http://scottmoniz.com/programmingBlog/?p=262</guid>
		<description><![CDATA[This tutorial will teach you how to style your tables with css and get them to look professional. It's the little things that make a website that much better.]]></description>
			<content:encoded><![CDATA[
<!-- ALL ADSENSE ADS DISABLED -->
<p>On this blog, I have a post about using jquery to apply alternating table row coloring. Someone commented that they couldnt quite get it working and needed an example. So, while making the example for him, I figure it would be a good post to show how to style a table professionally with CSS.</p>
<p>So, were going to start with this markup: <strong><br />
Note: You only need to load jquery and jquery.scripts if you want to do the last part of this example</strong>.</p>
<p>&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;title&gt;Table Row Coloring Example&lt;/title&gt;<br />
&lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt; &lt;!--load jquery--&gt;<br />
&lt;script type="text/javascript" src="jquery.scripts.js"&gt;&lt;/script&gt; &lt;!--load our custom jquery file--&gt;<br />
&lt;link rel="stylesheet" type="text/css" href="style.css"/&gt;&lt;!--load our css styles--&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;table&gt;<br />
&lt;th&gt;id&lt;/th&gt;<br />
&lt;th&gt;First name&lt;/th&gt;<br />
&lt;th&gt;Last name&lt;/th&gt;<br />
&lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;Scott&lt;/td&gt;&lt;td&gt;Moniz&lt;/td&gt;&lt;/tr&gt;<br />
&lt;tr class="row2"&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;Bob&lt;/td&gt;&lt;td&gt;Barker&lt;/td&gt;&lt;/tr&gt;<br />
&lt;/table&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p>
<p>Alright, now that we have that done. We area going to create style.css and add a few rules.</p>
<p>Here is the table selector:<br />
table{</p>
<p>border: 1px solid #ccc;<br />
}</p>
<p>well....that doesnt look very good..YET.<br />
Lets add a rule to the header. We'll add a background color.</p>
<p>table th{<br />
background-color: #ccc;<br />
}</p>
<p>Lets add a rule to the table data tags.<br />
table tr{<br />
border: 1px solid #ccc;<br />
}</p>
<p>Now, lets see what we got so far.<br />
<a href="http://theinfiniteloopblog.com/wp-content/uploads/2009/09/tabletut1.jpg"><img class="aligncenter size-full wp-image-263" title="tabletut1" src="http://theinfiniteloopblog.com/wp-content/uploads/2009/09/tabletut1.jpg" alt="tabletut1" width="173" height="84" /></a>Not too bad. You'll notice the headers are a little to close, and the borders dont look too great. Don't worry well fix that. Lets add another couple rules to table th and td.<br />
table th{<br />
border: 1px solid #000;<br />
padding: 5px;<br />
}<br />
table td{<br />
padding: 2px;<br />
}</p>
<p>Alright..lookin good so far. Here's what you should have:<br />
<a href="http://theinfiniteloopblog.com/wp-content/uploads/2009/09/tabletut2.jpg"><img class="aligncenter size-full wp-image-264" title="tabletut2" src="http://theinfiniteloopblog.com/wp-content/uploads/2009/09/tabletut2.jpg" alt="tabletut2" /></a>Lets take care of these ugly borders.</p>
<p>On our table selector we will add this rule:</p>
<p>table{<br />
border-collapse: collapse;<br />
}</p>
<p>If you look at the table, you'll notice that on the 2nd row there is a  class="row2". We will now style that class.<br />
table tr.row2{background-color: #EBEBEB;}</p>
<p>DONE. The final result looks like this.</p>
<p><a href="http://theinfiniteloopblog.com/wp-content/uploads/2009/09/tabletut3.jpg"><img class="aligncenter size-full wp-image-266" title="tabletut3" src="http://theinfiniteloopblog.com/wp-content/uploads/2009/09/tabletut3.jpg" alt="tabletut3" width="205" height="88" /></a></p>
<p>You can always modify the styles as you wish.</p>
<p>Tip: Every 2nd row, add the class="row2" to the row to get the alternating row colors. Optionally, add text-align: center; to the table selector.<br />
<a href="http://coulditgetworse.com/theinfiniteloopblog/wp-content/uploads/2009/09/tabletut4.jpg"><img class="aligncenter size-full wp-image-267" title="tabletut4" src="http://coulditgetworse.com/theinfiniteloopblog/wp-content/uploads/2009/09/tabletut4.jpg" alt="tabletut4" width="190" height="186" /></a>Here's the full CSS: <strong><br />
</strong>table{border: 1px solid #ccc;border-collapse:collapse; text-align: center;}<br />
table th{background-color: #ccc; padding: 5px; border: 1px solid #000;}<br />
table td{border: 1px solid #ccc; padding: 2px;}<br />
table tr.row2{background-color: #EBEBEB;}<br />
<strong><br />
Keep reading for an easy way to alternate row colors when you have a lot of rows.</strong><br />
Alright, now, if your table has 20 rows, maybe even 50, or 100, adding row2 manually is really a pain...and I personally wouldn't do that. We will use jquery to color the alternate rows.</p>
<p>Find the &lt;tr class="row2"&gt; and change it to &lt;tr&gt;. If you load the table you'll notice the alternate rows aren't colored anymore. We will now add a class to the table. So &lt;table&gt; should look like this &lt;table class="altcolor"&gt;.</p>
<p>Now that our table is setup, we will use a jquery selector to color rows in any table that has the class altcolor.<br />
You should have jquery.js  and you should create a file named jquery.scripts.js.<br />
Open jquery.scripts.js and add the following:</p>
<p><strong>$("document").ready(function(){<br />
$("table.altcolor tr:even").addClass("row2");<br />
});</strong></p>
<p>This loads when the webpage is ready<br />
//Notice the selector ?<br />
table.altcolor tr:even means any even row, in a table, that has the class "altcolor"<br />
Now we just call addClass, which will add the class row2.<br />
now, the class row2 is added to every even row in a table with the class altcolor.</p>
<p>Done. <img src='http://theinfiniteloopblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> <br />
If you don't get the same result, you might want to download the example source and check it out.</p>
<p><a href="http://theinfiniteloopblog.com/wp-content/uploads/2009/09/table-example.zip">Download Table Styling Example</a></p>
<p>Tip: When using jquery to style alternate rows, check your table with javascript disabled.<br />
For example, if you style your tables to have white text, and your row2 is supposed to apply a dark background to make the white text show up, if they have javascript disabled, they won't see the white text. Be careful and make sure your table looks good with and without javascript.</p>
]]></content:encoded>
			<wfw:commentRss>http://theinfiniteloopblog.com/programming/professional-table-styling-using-css/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Easy Javascript Validation using JQuery</title>
		<link>http://theinfiniteloopblog.com/programming/easy-javascript-validation-using-jquery/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=easy-javascript-validation-using-jquery</link>
		<comments>http://theinfiniteloopblog.com/programming/easy-javascript-validation-using-jquery/#comments</comments>
		<pubDate>Sun, 13 Sep 2009 03:45:55 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[XHTML/CSS]]></category>
		<category><![CDATA[easy javascript validation]]></category>
		<category><![CDATA[easy jquery validation]]></category>
		<category><![CDATA[easy jquery validator]]></category>
		<category><![CDATA[jquery validation plugin]]></category>
		<category><![CDATA[jquery validator]]></category>
		<category><![CDATA[jquery validator plugin]]></category>
		<category><![CDATA[jquery.validator.js]]></category>

		<guid isPermaLink="false">http://scottmoniz.com/programmingBlog/?p=234</guid>
		<description><![CDATA[Now, there might be other tools out there, but this is how I do mine. I like to write stuff from scratch but I actually feel like this little script would make life easier for a lot of people. You're free to use this as long as you leave the copyright in there. First download [...]]]></description>
			<content:encoded><![CDATA[
<!-- ALL ADSENSE ADS DISABLED -->
<p>Now, there might be other tools out there, but this is how I do mine. I like to write stuff from scratch but I actually feel like this little script would make life easier for a lot of people. You're free to use this as long as you leave the copyright in there.</p>
<p>First download jQuery and this script:  <a title="Jquery Validator" href="http://theinfiniteloopblog.com/wp-content/uploads/2009/09/jquery.validator.js"> jquery.validator.js</a> (Right click&gt;Save As)<br />
Next, add these lines.</p>
<p>&lt;script src="jquery.js" type="text/javascript"&gt;&lt;/script&gt;<br />
&lt;script src="jquery.validator.js" type="text/javascript"&gt;&lt;/script&gt;</p>
<p>When you create your forms create them like this.<br />
The form must have an id, and it must have the class "validate".<br />
Add the class 'req' for any fields that are required.<br />
Coming soon: email, int verification, age, etc.</p>
<pre>&lt;form <strong>id</strong>="contactform" action="whatever_action_you_want.php" <strong>class</strong>="validate"&gt;
&lt;input type="text" name="firstname" class="req"/&gt;&lt;span class="val"&gt;*&lt;/span&gt;
&lt;input type="text" name="lastname" class="req"/&gt;&lt;span class="val"&gt;*&lt;span&gt;
&lt;select name="country req"&gt;
&lt;option value=""&gt;Please select&lt;/option&gt;
&lt;option value="CA"&gt;Canada&lt;/option&gt;
&lt;/select&gt;
&lt;/form&gt;</pre>
<p>In your css add these<br />
span.val{visibility: hidden; color: red; font-weight:bold;}</p>
<p>Thats it.</p>
<p>If you guys post comments and subscribe, I can let you know when i further develop this. It will include number verification, email verification, postal code verification. It's very simple and lightweight and will shave time off any project. File (Right click>Save As): <a href="http://theinfiniteloopblog.com/wp-content/uploads/2009/09/jquery.validator.js">jquery.validator</a></p>
]]></content:encoded>
			<wfw:commentRss>http://theinfiniteloopblog.com/programming/easy-javascript-validation-using-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Embedding flash using SWFObject</title>
		<link>http://theinfiniteloopblog.com/programming/embedding-flash-using-swfobject/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=embedding-flash-using-swfobject</link>
		<comments>http://theinfiniteloopblog.com/programming/embedding-flash-using-swfobject/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 10:09:53 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[XHTML/CSS]]></category>
		<category><![CDATA[flash embed]]></category>
		<category><![CDATA[flash embedding]]></category>
		<category><![CDATA[swfobject embed]]></category>
		<category><![CDATA[swfobject flash help]]></category>
		<category><![CDATA[swfobject flash method]]></category>
		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://scottmoniz.com/programmingBlog/?p=229</guid>
		<description><![CDATA[Just to save some of you the headache . I spent a few hours on this today, and I couldn't figure it out, I've embedded flash many times before and I just couldn't figure out why this time it wasn't working. Anyways Using jquery found here: http://docs.jquery.com/Downloading_jQuery and jquery swfobject plugin found here: http://jquery.thewikies.com/swfobject/downloads we [...]]]></description>
			<content:encoded><![CDATA[
<!-- ALL ADSENSE ADS DISABLED -->
<p>Just to save some of you the headache <img src='http://theinfiniteloopblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . I spent a few hours on this today, and I couldn't figure it out, I've embedded flash many times before and I just couldn't figure out why this time it wasn't working.</p>
<p>Anyways</p>
<p>Using jquery found here: http://docs.jquery.com/Downloading_jQuery<br />
and<br />
jquery swfobject plugin found here: http://jquery.thewikies.com/swfobject/downloads</p>
<p>we can semantically embed flash.</p>
<p>Now a few things:</p>
<pre>
&lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="jquery.swfobject.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="jquery.myscript.js"&gt;&lt;/script&gt;</pre>
<p>Make SURE these are in this EXACT order.<br />
Load Jquery>Load its plugins>Load your javascript file.</p>
<p>Now on your page somewhere you will have the div you want to load flash into like so:<br />
&lt;div id="myflashdiv"&gt;&lt;/div&gt;</p>
<p>Open up jquery.myscript.js and type:</p>
<pre>
$("document").ready(function(){
       $("#myflashdiv").flash({
               swf: 'flash/myflash.swf'
        });
});
</pre>
<p>Directory Structure:</p>
<pre>
flash
  -myflash.swf
script
  -jquery.myscript.js
index.html
</pre>
<p>This assumes you have a flash folder, and the file myflash.swf in that folder.<br />
The path in this case is NOT relative to the script your working in. Think about it this way:<br />
the flash method probably uses document.write to output the correct object tag for your flash.<br />
If your page is on the root of your site and the script is in scripts/jquery.myscripts.js you would think the source for the swf would be "../flash/myflash.swf". But think about that..in index.html if you look at the output it would say: src="../flash/myflash.swf", you should be able to see why thats wrong if you look at the above directory structure.</p>
<p>Anyways, if you didn't know swfobject behaves this way, this could take you quite some time to figure out.<br />
Hope I saved you that time <img src='http://theinfiniteloopblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Troubleshooting<br />
Tip 1: Make sure the load order is : jquery, jquery.swfobject.js, then your script.<br />
Tip 2: Make sure the src you're passing in  is relative to the page you're embedding on, NOT relative to the script file you're working in.</p>
]]></content:encoded>
			<wfw:commentRss>http://theinfiniteloopblog.com/programming/embedding-flash-using-swfobject/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom Javascript Alert and Confirm Dialog boxes</title>
		<link>http://theinfiniteloopblog.com/programming/jscript/custom-javascript-alert-and-confirm-dialog-boxes/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=custom-javascript-alert-and-confirm-dialog-boxes</link>
		<comments>http://theinfiniteloopblog.com/programming/jscript/custom-javascript-alert-and-confirm-dialog-boxes/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 18:50:54 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[XHTML/CSS]]></category>
		<category><![CDATA[change javascript alert button]]></category>
		<category><![CDATA[change javascript alerts]]></category>
		<category><![CDATA[change javascript button text]]></category>
		<category><![CDATA[change javascript confirm button text]]></category>
		<category><![CDATA[custom dialog boxes]]></category>
		<category><![CDATA[custom javascript alerts]]></category>
		<category><![CDATA[custom javascript dialog boxes]]></category>

		<guid isPermaLink="false">http://scottmoniz.com/programmingBlog/?p=204</guid>
		<description><![CDATA[This article will teach you how to make Custom Javascript Alert and Confirm Dialog boxes, and change the button text on dialog boxes. For the most part, custom alert and confirm dialogs are not possible because alert and confirm dialog boxes are handled by the browser, however, there is a great JQuery plugin that will [...]]]></description>
			<content:encoded><![CDATA[
<!-- ALL ADSENSE ADS DISABLED -->
<h2>This article will teach you how to make Custom Javascript Alert and Confirm Dialog boxes, and change the button text on dialog boxes.</h2>
<p>For the most part, custom alert and confirm dialogs are not possible because alert and confirm dialog boxes are handled by the browser, however, there is a great JQuery plugin that will let you customize your alert boxes. If you don't know JQuery, do not worry, because i'll take you through it step by step. This little customization can make your web application that much more professional.</p>
<p>This will show you a little tutorial on how to make the custom alert and confirm dialogs AND <strong>How to return values from a custom confirm dialog box</strong>. This is EXTREMELY important. I have seen a lot of tutorials on how to do this, but none of them talk about actually <strong>retrieving the value of the response  in a custom confirm dialog box.</strong>.</p>
<h2>Custom Javascript Alert Dialog Boxes</h2>
<p><strong>Step 1 : Download <a href="http://docs.jquery.com/Downloading_jQuery">JQuery</a></strong></p>
<p>Click on Current Release, you can click Uncompressed if you want to inspect the code, but you should use minified version for production.</p>
<p>In our site, we will make a folder called scripts, and we will put the jquery.js file into this folder.<br />
We will also make a new file in the same folder named jquery.scripts.js.</p>
<p><strong>Step 2: Download </strong><a href="http://theinfiniteloopblog.com/wp-content/uploads/2009/07/jquery.alerts.js">jquery.alerts (Right click, Save as)</a>  and the css here: <a href='http://theinfiniteloopblog.com/wp-content/uploads/2009/07/jquery.alerts.css'>jquery.alerts.css</a><br />
</a> NOTE: This plugin is no longer supported by http://abeautifulsite.net/, so use it at your own risk.</p>
<p>We will put the jquery.alerts.js into the scripts folder, and the jquery.alerts.css into a styles folder.</p>
<p><strong>Step 3: The Setup</strong><br />
In our webpage we will add the references to these file.</p>
<p>&lt;script type="text/javascript" src="scripts/jquery.js"&gt;&lt;/script&gt;<br />
&lt;script type="text/javascript" src="scripts/jquery.scripts.js"&gt;&lt;/script&gt;<br />
&lt;script type="text/javascript" src="scripts/jquery.alerts.js"&gt;&lt;/script&gt;<br />
&lt;link href="styles/jquery.alerts.css" rel="stylesheet"/&gt;</p>
<p>Once we have all these references in, we're ready to write some jquery.</p>
<p><strong>Step 4: Open jquery.scripts.js</strong><br />
Type</p>
<p>$("document").ready(function(){</p>
<p>});</p>
<p>This sets up a function to be run when our document is ready.</p>
<p>In this document.ready function, type<br />
alert('jquery loaded');</p>
<p>Refreshing your webpage, you should see an alert saying "jquery loaded", if you see this, you have setup jquery correctly. If you do not, check the steps above, or hit CTRL+F5, this does a cache refresh and requests a new copy of all the javascript and css files.</p>
<p>We will add a button to our site.<br />
&lt;input type="button" value="Custom Alert" id="customAlert"/&gt;</p>
<p>In our document ready function, we will hook up a handler to handle the "click" event of this button.</p>
<p>$("document").ready(function(){<br />
$("#customAlert").click(function(){<br />
alert('this is an alert');<br />
});<br />
});</p>
<p>If you refresh your webpage (CTRL+F5) and click the button, you should see a normal javascript popup.<br />
Now, change the alert to jAlert.<br />
jAlert('this is a custom alert', 'this is a custom title');</p>
<p>Upon refreshing the page, and clicking the button, you should see a custom grey alert box.<strong> </strong>The styles can be modified by editing jquery.alerts.css.</p>
<p><strong>If you'd like to read on Custom confirm dialog boxes, please continue reading.</strong><br />
By this point, jquery and the jquery alerts plugin and css should be setup.<br />
Follow the above tutorial until you get to the actual jAlert method.</p>
<p><em>Comment if this helped! <img src='http://theinfiniteloopblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </em></p>
<h2>Custom Javascript Confirm Dialog Boxes</h2>
<p>Now, we will do a <strong>Custom Javascript Confirm Dialog.</strong><br />
The confirm function looks like this<br />
<strong>jConfirm('msg', '[title]', [callback function]);</strong></p>
<p>$("document").ready(function(){<br />
$("#btnID").click(function(){<br />
jConfirm('Would you like Ice Cream', 'msgBox Title', function(r){<br />
if(r){<br />
alert('you replied yes!');<br />
}else{<br />
alert('you replied no!');<br />
}<br />
}<br />
});<br />
});<br />
This is the basic implementation of custom confirm boxes, however you can still customize these a little further.</p>
<h2><strong>Changing Javascript Alert Button Text</strong></h2>
<p>Before calling jAlert or jConfirm, you can set the button text.</p>
<p>$.alerts.okButton="OKAYYYYYYYYYY";<br />
$.alerts.cancelButton="CANCELLLLLLLLLL";</p>
<p>This is also useful for localization.<br />
For example in an english jquery.scripts.js you can have.</p>
<p>$.alerts.okButton = "yes";<br />
$.alerts.cancelButton = "no";</p>
<p>And in a french jquery.scripts.js you can have</p>
<p>$.alerts.okButton="oui";<br />
$.alerts.okButton="non";</p>
<p>Hopefully this helped you add that little extra touch.<br />
For reference, here are the 2 methods, only the msg parameter is required.</p>
<p>jAlert('msg', '[title]', [callback function]);<br />
jConfirm('msg', '[title]', [callback functoin]);</p>
<p>There you have it!<br />
<em><strong>Please comment if this was helpful <img src='http://theinfiniteloopblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </strong></em><br />
Goodluck with your custom javascript!</p>
]]></content:encoded>
			<wfw:commentRss>http://theinfiniteloopblog.com/programming/jscript/custom-javascript-alert-and-confirm-dialog-boxes/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Using javascript to opening a new window W3C Validation target=&quot;_blank&quot; alternative</title>
		<link>http://theinfiniteloopblog.com/gen/semantically-opening-a-new-window-instead-of-using-target_blank/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=semantically-opening-a-new-window-instead-of-using-target_blank</link>
		<comments>http://theinfiniteloopblog.com/gen/semantically-opening-a-new-window-instead-of-using-target_blank/#comments</comments>
		<pubDate>Thu, 18 Jun 2009 02:05:29 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[XHTML/CSS]]></category>
		<category><![CDATA[javascript open link in new window]]></category>
		<category><![CDATA[javascript open new window]]></category>
		<category><![CDATA[open link in new window]]></category>
		<category><![CDATA[open link in new window strict]]></category>
		<category><![CDATA[open link in new window validation]]></category>
		<category><![CDATA[open link in new window xhtml strict]]></category>
		<category><![CDATA[target="_blank" semantically]]></category>
		<category><![CDATA[W3C Validation]]></category>

		<guid isPermaLink="false">http://scottmoniz.com/programmingBlog/?p=170</guid>
		<description><![CDATA[&#60;a href="http://www.google.com" target="_blank"&#62;Google!&#60;/a&#62; Perfect way to open a new window right? WRANG! (End of the world flash reference ...look it up) Your webpages may not pass W3C validation because your still using target="_blank". This article will show you how to use javascript or jquery to open a new window, and have your webpages pass W3C [...]]]></description>
			<content:encoded><![CDATA[
<!-- ALL ADSENSE ADS DISABLED -->
<p>&lt;a href="http://www.google.com" target="_blank"&gt;Google!&lt;/a&gt;<br />
Perfect way to open a new window right? WRANG! (End of the world flash reference ...look it up)</p>
<p>Your webpages may not pass W3C validation because your still using target="_blank".<br />
This article will show you how to use javascript or jquery to open a new window, and have your webpages pass W3C Strict Validation.</p>
<p>Anyyyyyyyyyyyways, using the target attribute of the a tag was a perfectly valid way of opening a link in a new window. However, this currently does not pass certain XHTML Validations. I assume you found this blog post because you need to validate and target="_blank" isn't passing.</p>
<p>This solution will open your link in a new window.<br />
&lt;a href="http://www.google.com" onclick="window.open(this.href);return false;"&gt;Google New Window!&lt;/a&gt;</p>
<p>What this does is use window.open, and passes the links href attribute as the url.<br />
The reason for "return false", is so that the base web page does not open the link as well.</p>
<p>Another cool alternative is to use JQuery...ya I know this is javascript but if you have jquery already loaded you can add this to your document.ready function.</p>
<p>$(document).ready(function(){<br />
$("a.newWin").click(function(){<br />
window.open($(this).attr("href"));<br />
return false;<br />
});<br />
});</p>
<p>&lt;a href="http://www.google.com" class="newWin"&gt;Google&lt;/a&gt;</p>
<p>Any link with the class newWin will now open in a new window.</p>
<p>Both these methods validate to XHTML Strict and are easy to implement.</p>
<p>Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://theinfiniteloopblog.com/gen/semantically-opening-a-new-window-instead-of-using-target_blank/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

