<?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>web2.0goodies.com &#187; javascript</title>
	<atom:link href="http://web2.0goodies.com/blog/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://web2.0goodies.com/blog</link>
	<description>Tips, Tricks, and How To's for Web 2.0</description>
	<lastBuildDate>Tue, 03 Jan 2012 05:34:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>How to obtain a users time zone via Javascript</title>
		<link>http://web2.0goodies.com/blog/javascript/how-to-obtain-a-users-time-zone-via-javascript/</link>
		<comments>http://web2.0goodies.com/blog/javascript/how-to-obtain-a-users-time-zone-via-javascript/#comments</comments>
		<pubDate>Tue, 03 Jan 2012 05:34:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://web2.0goodies.com/blog/?p=234</guid>
		<description><![CDATA[This approach isn&#8217;t perfect, but for US users, it should be correct 100% of the time. This blog author describes how he has created a function that uses the Javascript Date objects getTimeZoneOffset method to test various dates and determine what timezone the users computer is likely set to. Here is the post: http://blog.redfin.com/devblog/2007/08/getting_the_time_zone_from_a_web_browser.html]]></description>
			<content:encoded><![CDATA[<p>This approach isn&#8217;t perfect, but for US users, it should be correct 100% of the time.</p>
<p>This blog author describes how he has created a function that uses the Javascript Date objects getTimeZoneOffset method to test various dates and determine what timezone the users computer is likely set to.</p>
<p>Here is the post: <a href="http://blog.redfin.com/devblog/2007/08/getting_the_time_zone_from_a_web_browser.html" target="_blank">http://blog.redfin.com/devblog/2007/08/getting_the_time_zone_from_a_web_browser.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://web2.0goodies.com/blog/javascript/how-to-obtain-a-users-time-zone-via-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Google CDN jQuery and jQuery ui.</title>
		<link>http://web2.0goodies.com/blog/javascript/using-google-cdn-jquery-and-jquery-ui/</link>
		<comments>http://web2.0goodies.com/blog/javascript/using-google-cdn-jquery-and-jquery-ui/#comments</comments>
		<pubDate>Thu, 28 Jul 2011 07:06:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://web2.0goodies.com/blog/?p=220</guid>
		<description><![CDATA[I add these to almost every page I create. Next time you want to include jQuery and jQuery ui in a page, just copy these three tags and drop them in your head. Viola! jQuery, courtesy of Google! And if everybody did this, the web would be faster&#8230;]]></description>
			<content:encoded><![CDATA[<p>I add these to almost every page I create.  Next time you want to include jQuery and jQuery ui in a page, just copy these three tags and drop them in your head.  Viola!  jQuery, courtesy of Google!  And if everybody did this, the web would be faster&#8230;</p>
<pre name="code" class="html">
<link rel="stylesheet" type="text/css" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/themes/base/jquery-ui.css">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.js"></script>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://web2.0goodies.com/blog/javascript/using-google-cdn-jquery-and-jquery-ui/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Escaping Strings for use in Javascript from PHP</title>
		<link>http://web2.0goodies.com/blog/javascript/escaping-strings-for-use-in-javascript-from-php/</link>
		<comments>http://web2.0goodies.com/blog/javascript/escaping-strings-for-use-in-javascript-from-php/#comments</comments>
		<pubDate>Mon, 20 Jun 2011 18:59:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://web2.0goodies.com/blog/javascript/escaping-strings-for-use-in-javascript-from-php/</guid>
		<description><![CDATA[I ran into a problem today on an application where building some inline javascript (which btw I NEVER recommend, I inherited this from someone else&#8230;   Write javascript that takes an object as a param and use json_encode instead&#8230;)&#8230;  And some data in our database had carriage returns&#8230;  Which was breaking our javascript.  I wanted to [...]]]></description>
			<content:encoded><![CDATA[<p>I ran into a problem today on an application where building some inline javascript (which btw I NEVER recommend, I inherited this from someone else&#8230;   Write javascript that takes an object as a param and use json_encode instead&#8230;)&#8230;  And some data in our database had carriage returns&#8230;  Which was breaking our javascript.  I wanted to escape the string before putting it in the javascript but I didn&#8217;t want to write my own function.  After doing some searching, I discovered that json_encode will return a valid javascript string if you pass it a string instead of an array!!!</p>
<p>Note:  json_encode will put double quotes on the end of your string, so to fix this, you need to strip them&#8230; Use preg_replace:</p>
<pre>

function javascript_encode($toEncode){
  return preg_replace("/^\"(.*)\"$/", "$1", json_encode($toEncode));
}
</pre>
<p>Cheers!</p>
<p>Joey</p>
]]></content:encoded>
			<wfw:commentRss>http://web2.0goodies.com/blog/javascript/escaping-strings-for-use-in-javascript-from-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Printing From Javascript</title>
		<link>http://web2.0goodies.com/blog/javascript/printing-from-javascript/</link>
		<comments>http://web2.0goodies.com/blog/javascript/printing-from-javascript/#comments</comments>
		<pubDate>Fri, 17 Jun 2011 08:11:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://web2.0goodies.com/blog/javascript/printing-from-javascript/</guid>
		<description><![CDATA[This one is easy&#8230; window.print();]]></description>
			<content:encoded><![CDATA[<p>This one is easy&#8230;</p>
<p><code></code><font face="Courier New"><br />
  window.print();<br />
</font></p>
]]></content:encoded>
			<wfw:commentRss>http://web2.0goodies.com/blog/javascript/printing-from-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Page refresh with JavaScript</title>
		<link>http://web2.0goodies.com/blog/javascript/page-refresh-with-javascript/</link>
		<comments>http://web2.0goodies.com/blog/javascript/page-refresh-with-javascript/#comments</comments>
		<pubDate>Thu, 16 Jun 2011 19:01:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[code snippets]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://web2.0goodies.com/blog/javascript/page-refresh-with-javascript/</guid>
		<description><![CDATA[The easiest way is to do a: window.location.reload(); It is important though that you use the &#8220;POST/Redirect/Get&#8221; pattern on your pages, otherwise a window.location.reload() will cause the browser to resend any post data it sent on the last request.&#160;]]></description>
			<content:encoded><![CDATA[<p>The easiest way is to do a: window.location.reload();</p>
<p>It is important though that you use the <a href="http://en.wikipedia.org/wiki/Post/Redirect/Get">&#8220;POST/Redirect/Get&#8221; pattern</a> on your pages, otherwise a window.location.reload() will cause the browser to resend any post data it sent on the last request.&nbsp; </p>
]]></content:encoded>
			<wfw:commentRss>http://web2.0goodies.com/blog/javascript/page-refresh-with-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>nicEdit Firefox center and right align bug patch.</title>
		<link>http://web2.0goodies.com/blog/javascript/nicedit-firefox-center-and-right-align-bug-patch/</link>
		<comments>http://web2.0goodies.com/blog/javascript/nicedit-firefox-center-and-right-align-bug-patch/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 16:54:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[firefox]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[workarounds]]></category>
		<category><![CDATA[wysiwyg editors]]></category>

		<guid isPermaLink="false">http://web2.0goodies.com/blog/javascript/nicedit-firefox-center-and-right-align-bug-patch/</guid>
		<description><![CDATA[If you are using nicEdit on content editable areas instead of the iFrame method, then you may have run across the FireFox bug that prevents you from changing the text alignment on the first line of a content editable element.&#160; As a work around, change the nicCommand method in nicEdit.js (Line 610 or so), to [...]]]></description>
			<content:encoded><![CDATA[<p>If you are using nicEdit on content editable areas instead of the iFrame method, then you may have run across the FireFox bug that prevents you from changing the text alignment on the first line of a content editable element.&nbsp; </p>
<p>As a work around, change the nicCommand method in nicEdit.js (Line 610 or so), to the below.  This code catches the error that firefox throws, inserts a temporary div immediately before the selection, repeats the call that failed (the bug only causes the alignment to fail when it is the very first element in the content editable), and then removes the temporary div.</p>
<pre>
nicCommand : function(cmd, args) {
        if ((cmd == 'justifyright') || (cmd == 'justifyleft') || (cmd ==
        'justifycenter') || (cmd == 'justifyfull')) {
              try {
                 document.execCommand(cmd, false, null);
              }
              catch (e) {
                 //special case for Mozilla Bug #442186
                 if (e &amp;&amp; e.result == 2147500037) {
                    //probably firefox bug 442186 - workaround
                    var range = window.getSelection().getRangeAt(0);
                    var dummy = document.createElement('div');

                     //To restore the range after collapsing for triple click bug...
                     var restoreSelection = false;
                    dummy.style.height="1px;";

                    //find node with contentEditable

                    //Triple Click selection Problem in mozilla, the selection contains the content editable div, which creates a problem for some reason, so we collapse the selection to the end, and then re-select everything...
                    if(range.startContainer.contentEditable == 'true'){
                        window.getSelection().collapseToEnd();
                        restoreSelection = true;
                    }

                    var ceNode = window.getSelection().getRangeAt(0).startContainer;

                    while (ceNode &amp;&amp; ceNode.contentEditable != 'true')
                       ceNode = ceNode.parentNode;

                    if (!ceNode) throw 'Selected node is not editable!';

                    ceNode.insertBefore(dummy, ceNode.childNodes[0]);
                    document.execCommand(cmd, false, null);
                    dummy.parentNode.removeChild(dummy);

                     //RestoreSelection if we changed it...
                     if(restoreSelection){
                        window.getSelection().addRange(range);
                     }
                 } else if (console &amp;&amp; console.log) console.log(e);
              }
           } else {
              document.execCommand(cmd, false, args);
      }
    }
</pre>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" alt="" src="http://img.zemanta.com/pixy.gif?x-id=10a8a059-a566-8e45-9330-fcfb2c7438f2" /></div>
]]></content:encoded>
			<wfw:commentRss>http://web2.0goodies.com/blog/javascript/nicedit-firefox-center-and-right-align-bug-patch/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>JavaScript Primer</title>
		<link>http://web2.0goodies.com/blog/html/javascript-primer/</link>
		<comments>http://web2.0goodies.com/blog/html/javascript-primer/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 02:17:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://web2.0goodies.com/blog/?p=68</guid>
		<description><![CDATA[SOA powered by JavaScript is the future of the web.  Learn it now!]]></description>
			<content:encoded><![CDATA[<p>So you want to learn JavaScript huh?  Way to go!  SOA powered by JavaScript is the future of the web.  (Trust me).</p>
<p>What is JavaScript?  It&#8217;s a scripting language that all modern web browsers run that allows you to manipulate web pages and do sweet stuff.</p>
<p>To get started, first, you need an easy way to run JavaScript.  While you could write javascript in an html page and run it, it&#8217;s generally easier to be able to run scirpts without making an html page.  To do this, install <a href="https://addons.mozilla.org/en-US/firefox/addon/1843?id=1843&#038;application=firefox">Firebug</a>, and use it&#8217;s console.  (Just install firebug, click on the little cock-roach icon in the lower left of Firefox, and click the console tab, now reload your window.).</p>
<p>Once you have the firebug console working, type the following into the console, and you should get a popup.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Hello World!'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Here&#8217;s a video that shows how to install and use Firebug:</p>
<p><center><span class="youtube">
<object width="425" height="355">
<param name="movie" value="http://www.youtube.com/v/MK9PICm4LFA?color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;autoplay=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0&amp;rel=1" />
<param name="allowFullScreen" value="true" />
<param name="allowscriptaccess" value="always">
<embed src="http://www.youtube.com/v/MK9PICm4LFA?color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;autoplay=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0&amp;rel=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="425" height="355"></embed>
</object>
</span><p><a href="http://www.youtube.com/watch?v=MK9PICm4LFA">www.youtube.com/watch?v=MK9PICm4LFA</a></p></center></p>
<p>If you want to learn more, head over to w3schools&#8217; <a href="http://www.w3schools.com/JS/default.asp">JavaScript tutorial.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://web2.0goodies.com/blog/html/javascript-primer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

