<?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>dawnerd &#187; Javascript</title>
	<atom:link href="http://dawnerd.com/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://dawnerd.com</link>
	<description>Just another WordPress site</description>
	<lastBuildDate>Fri, 13 Aug 2010 18:20:31 +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>Making Internet Explorer HTML 5 Ready</title>
		<link>http://dawnerd.com/post/94_making-internet-explorer-html-5-ready/</link>
		<comments>http://dawnerd.com/post/94_making-internet-explorer-html-5-ready/#comments</comments>
		<pubDate>Sun, 09 Aug 2009 18:49:19 +0000</pubDate>
		<dc:creator>Troy Whiteley</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[browser quirks]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[Internet Explorer]]></category>

		<guid isPermaLink="false">http://dawnerd.com/?p=94</guid>
		<description><![CDATA[I&#8217;m going to come right out and say that it&#8217;s likely to take IE years before we see native HTML 5 support. However, that doesn&#8217;t mean we should ignore HTML 5 until IE gets with the program. If you&#8217;ve tried &#8230; <a href="http://dawnerd.com/post/94_making-internet-explorer-html-5-ready/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m going to come right out and say that it&#8217;s likely to take IE years before we see native HTML 5 support. However, that doesn&#8217;t mean we should ignore HTML 5 until IE gets with the program.</p>
<p>If you&#8217;ve tried to mess around with HTML 5 in IE, you may have noticed that the new elements do not work correctly with css. Luckily for us, we can use a tiny bit of Javascript to trick IE into rending the HTML 5 elements correctly.</p>
<p><span id="more-94"></span></p>
<pre>
<code>
document.createElement('header');
document.createElement('footer');
document.createElement('aside');
document.createElement('nav');
document.createElement('article');
document.createElement('section');
</code>
</pre>
<p>The above snippet of Javascript will enable HTML 5 support for the following elements: <code>header, footer, aside, nav, article, section</code>. Should you need support for another element, just use the createElement function and set the parameter to be the element name.</p>
<p>Remember that you should only include the JS file with the &#8216;HTML 5 emulation&#8217; code on IE.</p>
<p>Our next task in a later post is to emulate the <code>video</code> and <code>audio</code> elements.</p>
]]></content:encoded>
			<wfw:commentRss>http://dawnerd.com/post/94_making-internet-explorer-html-5-ready/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Open Source jQuery Plugin &#8211; AjaxPages</title>
		<link>http://dawnerd.com/post/83_open-source-jquery-plugin-ajaxpages/</link>
		<comments>http://dawnerd.com/post/83_open-source-jquery-plugin-ajaxpages/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 18:55:28 +0000</pubDate>
		<dc:creator>Troy Whiteley</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[interface design]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[user interface]]></category>

		<guid isPermaLink="false">http://dawnerd.com/?p=83</guid>
		<description><![CDATA[AjaxPages allows you to serve up full pages completely with ajax. This is very useful if you want to build a site that has a music player running across page loads, but don&#8217;t want to use frames. This technique can &#8230; <a href="http://dawnerd.com/post/83_open-source-jquery-plugin-ajaxpages/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://code.google.com/p/jquery-ajaxpages/">AjaxPages</a> allows you to serve up full pages completely with ajax. This is very useful if you want to build a site that has a music player running across page loads, but don&#8217;t want to use frames. This technique can be found at <a href="http://thesixtyone.com">TheSixtyOne</a>.</p>
<p>All internal links should be in hash format. Example: instead of linking to <code>filename.html</code>, you would link to <code>#/filename.html</code>.</p>
<p>If you have clean urls on, the hash is almost not noticeable. Example: <code>domain.com/#/profile/username</code></p>
<p>To get started with AjaxPages, get the files from the <a href="http://code.google.com/p/jquery-ajaxpages/source/browse/#svn/trunk">Google Code trunk</a>. Example files are included. That should be enough to get you started. The plugin is very lightweight and fairly simple so it should not give you any problems.</p>
<p>If you need help, please leave a comment and I will personally help you out.</p>
]]></content:encoded>
			<wfw:commentRss>http://dawnerd.com/post/83_open-source-jquery-plugin-ajaxpages/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Open Source jQuery Plugin &#8211; Custom Radio and Checkboxes</title>
		<link>http://dawnerd.com/post/62_open-source-jquery-plugin-custom-radio-and-checkboxes/</link>
		<comments>http://dawnerd.com/post/62_open-source-jquery-plugin-custom-radio-and-checkboxes/#comments</comments>
		<pubDate>Tue, 24 Mar 2009 07:15:40 +0000</pubDate>
		<dc:creator>Troy Whiteley</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[user interface]]></category>

		<guid isPermaLink="false">http://dawnerd.com/?p=62</guid>
		<description><![CDATA[I got fed up with the numerous amounts of plugins that handle custom checkboxes and radio inputs that I decided to create my own. Typically, the plugin will create html for you in which you an style. But you also &#8230; <a href="http://dawnerd.com/post/62_open-source-jquery-plugin-custom-radio-and-checkboxes/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I got fed up with the numerous amounts of plugins that handle custom checkboxes and radio inputs that I decided to create my own. Typically, the plugin will create html for you in which you an style. But you also have to pass in url&#8217;s for images that will be used for the various states.</p>
<p>The plugin I created, <a href="http://code.google.com/p/jquery-bltcheckbox/">bltcheckbox</a>, allows you to use any html and css. The only options you pass to the plugin are whether it&#8217;s a checkbox, or a radio input.</p>
<p>For code samples and documentation, please check out the code code page <a href="http://code.google.com/p/jquery-bltcheckbox/">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://dawnerd.com/post/62_open-source-jquery-plugin-custom-radio-and-checkboxes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixing Common CSS Issues In IE6 and IE7</title>
		<link>http://dawnerd.com/post/60_fixing-common-css-issues-in-ie6-and-ie7/</link>
		<comments>http://dawnerd.com/post/60_fixing-common-css-issues-in-ie6-and-ie7/#comments</comments>
		<pubDate>Tue, 21 Oct 2008 06:05:01 +0000</pubDate>
		<dc:creator>Troy Whiteley</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[browser quirks]]></category>

		<guid isPermaLink="false">http://dawnerd.com/?p=60</guid>
		<description><![CDATA[As it turns out, Microsoft really doesn&#8217;t care about web standards at all. It has taken them way too many years to adopt the basics of CSS2 correctly. Now they are trying to expand that with IE8. However, developers still &#8230; <a href="http://dawnerd.com/post/60_fixing-common-css-issues-in-ie6-and-ie7/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>As it turns out, Microsoft really doesn&#8217;t care about web standards at all. It has taken them way too many years to adopt the basics of CSS2 correctly. Now they are trying to expand that with IE8. However, developers still have to deal with the outdated IE6 and IE7. Using min-width is completely pointless unless your user base only uses good browsers. <span id="more-60"></span></p>
<p>The other day, I literally stumbled upon a JS file that fixes most of the IE6 and IE7 bugs. It emulates a lot of missing CSS functionality, and also applies a generic PNG fix. <a href="http://code.google.com/p/ie7-js/">You can find the file here</a>. I have been using it on all of my projects recently. In combination with a <a href="http://meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/">css reset stylesheet</a> and the IE7 JS file, I have had a lot less headaches. I say you give it a shot. it&#8217;s not like it will take a lot of work for you to at least try out.</p>
]]></content:encoded>
			<wfw:commentRss>http://dawnerd.com/post/60_fixing-common-css-issues-in-ie6-and-ie7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An Alternate Way To Bypass Javascript&#8217;s Same-Origin Policy</title>
		<link>http://dawnerd.com/post/15_an-alternate-way-to-bypass-javascripts-same-origin-policy/</link>
		<comments>http://dawnerd.com/post/15_an-alternate-way-to-bypass-javascripts-same-origin-policy/#comments</comments>
		<pubDate>Thu, 12 Jun 2008 03:42:40 +0000</pubDate>
		<dc:creator>Troy Whiteley</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[same orgin]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://dawnerd.com/?p=15</guid>
		<description><![CDATA[If you have worked with AJAX at all, you know that there is this thing called the Same-Origin policy which makes it nearly impossible to send AJAX requests to 3rd party domains. There are workarounds such as going through a &#8230; <a href="http://dawnerd.com/post/15_an-alternate-way-to-bypass-javascripts-same-origin-policy/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you have worked with AJAX at all, you know that there is this thing called the Same-Origin policy which makes it nearly impossible to send AJAX requests to 3rd party domains. There are workarounds such as going through a proxy. I don&#8217;t like that and think it&#8217;s messy. However, sometimes it&#8217;s the only way to go about getting the job done. This post is not about going through a proxy, instead, it is about using a little trick I learned from Yahoo.<span id="more-15"></span></p>
<p>If you have control over both domains, then this  may be the ideal solution for you. For example, lets say you have two sites and you need to share data between the sites. Connecting via MySQL could be out of the question. So what do you do now? Create a dynamic javascript include file.</p>
<pre>
<code>
<?php
//some database stuff here
echo "myVar = ['info1','info2','info3'];";
?>
</code>
</pre>
<p>See how that outputs a Javascript array? It will come in handy next.</p>
<pre>
<code>
<script src="domain2.com/dynamicscript.php" type="text/javascript"></script>
<script type="text/javascript">
for(i=1;i<myVar.length;i++)
{
    document.write("

"+myVar[i]+"

");
}
</script>
</code>
</pre>
<p>By including the dynamic.php file as if it were a javascript file, you have imported the data from the other domain without having to use ajax. You can use this to pass any amount of javascript you need. I&#8217;m sure if you&#8217;re clever you will figure out how to make this into a &#8220;mock AJAX&#8221; system.</p>
]]></content:encoded>
			<wfw:commentRss>http://dawnerd.com/post/15_an-alternate-way-to-bypass-javascripts-same-origin-policy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ajax Username Validation with The Most Popular JS Frameworks</title>
		<link>http://dawnerd.com/post/12_ajax-username-validation-with-the-most-popular-js-frameworks/</link>
		<comments>http://dawnerd.com/post/12_ajax-username-validation-with-the-most-popular-js-frameworks/#comments</comments>
		<pubDate>Fri, 23 May 2008 21:59:02 +0000</pubDate>
		<dc:creator>Troy Whiteley</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[prototype]]></category>
		<category><![CDATA[user interface]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://dawnerd.com/?p=12</guid>
		<description><![CDATA[It seems like every site these days uses some form of Ajax to validate form fields. One thing I cannot stand is websites that do not use Ajax to check usernames (or other data) as you type. Because a lot &#8230; <a href="http://dawnerd.com/post/12_ajax-username-validation-with-the-most-popular-js-frameworks/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>It seems like every site these days uses some form of Ajax to validate form fields. One thing I cannot stand is websites that do not use Ajax to check usernames (or other data) as you type. Because a lot of sites are lacking this one feature, I thought it would be nice to throw together a few examples of how to do it correctly with the most popular of JS frameworks. <span id="more-12"></span></p>
<p>You can view the source of the examples to see how they are done.</p>
<p><strong><a href="http://labs.dawnerd.com/ajaxusercheck_prototype/">Ajax Username Validation with Prototype</a></strong><br />
<strong><a href="http://labs.dawnerd.com/ajaxusercheck_jquery/">Ajax Username Validation with jQuery</a></strong></p>
<p><em>note: more examples will come in time. I am currently reading the mootools, dojo, and mochikit.</em></p>
<p>The only PHP code you will need is as follows:</p>
<pre>
<code markup="none">
include("../db.php");
$name = ereg_replace("[^A-Za-z0-9-]", "",mysql_real_escape_string(strip_tags(trim($_GET['name']))));
if(empty($name)) die();

$sql = "SELECT `username` FROM `common_usernames` WHERE `username` = '$name'";
$query = mysql_query($sql,$db);

if(!mysql_num_rows($query))
{
	die('<span style="font-weight:bold;color:green;font-size:12px;">'.$name.' is available!</span>');
}
else
{
	die('<span style="font-weight:bold;color:red;font-size:12px;">'.$name.' is taken!</span>');
}
</code>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://dawnerd.com/post/12_ajax-username-validation-with-the-most-popular-js-frameworks/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Emulate PHP&#8217;s Rand() Function in Javascript</title>
		<link>http://dawnerd.com/post/10_emulate-phps-rand-function-in-javascript/</link>
		<comments>http://dawnerd.com/post/10_emulate-phps-rand-function-in-javascript/#comments</comments>
		<pubDate>Tue, 20 May 2008 20:04:08 +0000</pubDate>
		<dc:creator>Troy Whiteley</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[random number]]></category>

		<guid isPermaLink="false">http://dawnerd.com/?p=10</guid>
		<description><![CDATA[Javascript&#8217;s random number generator is lacking a lot of power. To create a number between say 0 and 10, you can do this: number = Math.round(Math.random()*10); Of course you can modify this slightly to fit your needs, but this should &#8230; <a href="http://dawnerd.com/post/10_emulate-phps-rand-function-in-javascript/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Javascript&#8217;s random number generator is lacking a lot of power. To create a number between say 0 and 10, you can do this:</p>
<pre>
<code markup="none">
number = Math.round(Math.random()*10);
</code>
</pre>
<p>Of course you can modify this slightly to fit your needs, but this should be the basics needed.</p>
<p><strong>Edit:</strong> As pointed out, the code I supplied is not very random. If you need true random numbers, the mt_rand function supplied by the good guys at <a href="http://phpjs.org/functions/mt_rand:476">phpjs.org</a> is a great solution.</p>
<pre>
<code markup="none">
function mt_rand( min, max ) {
    // Returns a random number from Mersenne Twister
    //
    // version: 810.1317
    // discuss at: http://phpjs.org/functions/mt_rand
    // +   original by: Onno Marsman
    // *     example 1: mt_rand(1, 1);
    // *     returns 1: 1
    var argc = arguments.length;
    if (argc == 0) {
        min = 0;
        max = 2147483647;
    } else if (argc == 1) {
        throw new Error('Warning: mt_rand() expects exactly 2 parameters, 1 given');
    }
    return Math.floor(Math.random() * (max - min + 1)) + min;
}
</code>
</pre>
<p>I would suggest using the above when you need to generate random numbers. You should also check out the rest of <a href="http://phpjs.org/">phpjs</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://dawnerd.com/post/10_emulate-phps-rand-function-in-javascript/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Rollover Images Without Javascript</title>
		<link>http://dawnerd.com/post/9_rollover-images-without-javascript/</link>
		<comments>http://dawnerd.com/post/9_rollover-images-without-javascript/#comments</comments>
		<pubDate>Fri, 16 May 2008 05:29:44 +0000</pubDate>
		<dc:creator>Troy Whiteley</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://dawnerd.com/?p=9</guid>
		<description><![CDATA[One of the messiest things I have seen is the auto-generated code from Dreamweaver for rollover images. It got me thinking of ways to make the images swap without the need of Javascript. Instantly I thought CSS. It was actually &#8230; <a href="http://dawnerd.com/post/9_rollover-images-without-javascript/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>One of the messiest things I have seen is the auto-generated code from Dreamweaver for rollover images. It got me thinking of ways to make the images swap without the need of Javascript. Instantly I thought CSS. It was actually fairly simple to get working. <span id="more-9"></span></p>
<p>Take for example this button:</p>
<pre>
<code markup="none">
<a href="results.html" class="button"></a>
</code>
</pre>
<p>Right now the button doesn&#8217;t do a thing. However, if we apply some CSS to it, we get a nice button with a rollover.</p>
<pre>
<code markup="none">
.button{
    background:url('url/to/image.png') no-repeat;
    width:20px;
    height:20px;
    display:block;
}
.button:hover{
    background:url(url/to/rollover.png) no-repeat;
}
</code>
</pre>
<p>Now the button will show the image and swap to the rollover when you hover over it. All without Javascript. But, you ask &#8220;How do you preload the images without Javascript?&#8221;</p>
<p>I laugh, such a simple answer. Put the rollover images at the top of the page, inside of a hidden div.</p>
<pre>
<code markup="none">
<div style="display:none;">
    <img src="url/to/rollover.png" alt="" />
</div>

</code>
</pre>
<p>And there you have it, JS free rollover images.</p>
]]></content:encoded>
			<wfw:commentRss>http://dawnerd.com/post/9_rollover-images-without-javascript/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
