<?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>Kavoir &#187; JavaScript Tips &amp; Tutorials</title>
	<atom:link href="http://www.kavoir.com/category/programming/javascript-tips/feed" rel="self" type="application/rss+xml" />
	<link>http://www.kavoir.com</link>
	<description>Just another dumbass webmaster, goofing around...</description>
	<lastBuildDate>Thu, 09 Feb 2012 01:59:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to include a JavaScript file inside a JavaScript file?</title>
		<link>http://www.kavoir.com/2010/07/how-to-include-a-javascript-file-inside-a-javascript-file.html</link>
		<comments>http://www.kavoir.com/2010/07/how-to-include-a-javascript-file-inside-a-javascript-file.html#comments</comments>
		<pubDate>Wed, 21 Jul 2010 16:47:18 +0000</pubDate>
		<dc:creator>Yang Yang</dc:creator>
				<category><![CDATA[JavaScript Tips & Tutorials]]></category>

		<guid isPermaLink="false">http://www.kavoir.com/2010/07/how-to-include-a-javascript-file-inside-a-javascript-file.html</guid>
		<description><![CDATA[This is a pretty odd question to ask in the first place if you have been using JavaScript for a while. JavaScript files are called from HTML web pages who need them to manipulate the HTML elements so that the users have extraordinary interactive experience. You can’t include a JavaScript file inside another JavaScript file [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>This is a pretty odd question to ask in the first place if you have been using JavaScript for a while. JavaScript files are called from HTML web pages who need them to manipulate the HTML elements so that the users have extraordinary interactive experience. You can’t include a JavaScript file inside another JavaScript file like you can with PHP files, but you can only include JS files from HTML files.</p>

<p>If you need something that’s in a JavaScript file such as a predefined function, just include the file before wherever you are using the function and it should be fine. For example, you are calling A.js from a HTML file:</p>
<pre><code>&lt;body&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;A.js&quot;&gt;&lt;/script&gt;
&lt;/body&gt;</code></pre>
<p>There is a rather sophisticated function in B.js that A.js relies on. You are wondering how to include B.js in A.js so A.js works properly. No you can’t. The answer is not to include B.js in A.js but include B.js in the HTML file before it includes A.js.</p>
<pre><code>&lt;body&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;B.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;A.js&quot;&gt;&lt;/script&gt;
&lt;/body&gt;</code></pre>
<p>Now all the code in A.js should work fine. This is because all HTML code are read, parsed and executed in basic sequence from top to bottom. It’s the same with JavaScript code. When you need something from another JavaScript file and want to use it on the web page, just include it in the HTML web page. You can’t include a JavaScript file in a JavaScript file.</p>
<h3>Related Posts:</h3>
<ul class="similar-posts">
<li><a href="http://www.kavoir.com/2010/07/how-to-execute-run-php-code-inside-javascript-files.html" rel="bookmark" title="July 9, 2010">How to execute / run PHP code inside JavaScript files?</a></li>
<li><a href="http://www.kavoir.com/2010/07/php-and-javascript-variable-value-transfer-exchange-how-to-pass-variable-values-from-php-to-javascript-or-javascript-to-php.html" rel="bookmark" title="July 9, 2010">PHP and JavaScript Variable / Value Transfer / Exchange: How to pass variable values from PHP to JavaScript or JavaScript to PHP?</a></li>
<li><a href="http://www.kavoir.com/2010/02/php-why-you-should-use-dirname__file__-include-php-instead-of-just-include-php.html" rel="bookmark" title="February 9, 2010">PHP: Why you should use dirname(__FILE__).&lsquo;/include.php&rsquo; instead of just &lsquo;include.php&rsquo;</a></li>
<li><a href="http://www.kavoir.com/2009/04/php-send-html-email-mail.html" rel="bookmark" title="April 23, 2009">PHP: Send HTML Email (mail)</a></li>
<li><a href="http://www.kavoir.com/2009/01/php-run-html-as-php.html" rel="bookmark" title="January 19, 2009">PHP: Run HTML as PHP</a></li>
</ul>
<p><!-- Similar Posts took 2.336 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kavoir.com/2010/07/how-to-include-a-javascript-file-inside-a-javascript-file.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>JavaScript: How to set focus to form elements?</title>
		<link>http://www.kavoir.com/2010/07/javascript-how-to-set-focus-to-form-elements.html</link>
		<comments>http://www.kavoir.com/2010/07/javascript-how-to-set-focus-to-form-elements.html#comments</comments>
		<pubDate>Wed, 21 Jul 2010 16:31:47 +0000</pubDate>
		<dc:creator>Yang Yang</dc:creator>
				<category><![CDATA[JavaScript Tips & Tutorials]]></category>

		<guid isPermaLink="false">http://www.kavoir.com/2010/07/javascript-how-to-set-focus-to-form-elements.html</guid>
		<description><![CDATA[Normally, when users click on any label tag with the cursor, the corresponding input field will be focused ready for input or selection. Therefore, you can always achieve the focus effect by this native function of HTML&#8217;s. Otherwise, you’d need a small dime of JavaScript to set focus to any form element on the fly [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Normally, when users click on any label tag with the cursor, the corresponding input field will be focused ready for input or selection. Therefore, you can always achieve the focus effect by this native function of HTML&#8217;s. Otherwise, you’d need a small dime of JavaScript to set focus to any form element on the fly upon a certain event:</p>

<pre><code>// FormName is the name value of the form.
// FieldName is the name value of the field
// to be focused.
document.FormName.FieldName.focus();</code></pre>
<p>Or by element ID:</p>
<pre><code>// FieldId is the id value of the field
// element to be focused.
document.getElementById('FieldId').focus();</code></pre>
<p>There you go, the tiny <strong>focus</strong>() function is what we all need.</p>
<h3>Related Posts:</h3>
<ul class="similar-posts">
<li><a href="http://www.kavoir.com/2010/04/javascript-confirmation-warning-before-leaving-or-navigating-away-from-a-page.html" rel="bookmark" title="April 27, 2010">JavaScript: Confirmation / Warning before Leaving or Navigating Away from a Page</a></li>
<li><a href="http://www.kavoir.com/2007/09/dom-event-detection-event-bubbling-and-event-capturing.html" rel="bookmark" title="September 25, 2007">DOM event detection: event bubbling and event capturing</a></li>
<li><a href="http://www.kavoir.com/2010/03/html-content-editable-element-tags.html" rel="bookmark" title="March 5, 2010">HTML: Make Content Editable in Element / Tags without JavaScript</a></li>
<li><a href="http://www.kavoir.com/2009/02/styling-file-upload-select-input-control-input-typefile.html" rel="bookmark" title="February 8, 2009">CSS: Styling File Upload / Select Input Control &lt;input type=&quot;file&quot; &hellip; /&gt;</a></li>
<li><a href="http://www.kavoir.com/2009/01/php-file-upload-class.html" rel="bookmark" title="January 15, 2009">PHP: File Upload Script (HTML Form + PHP Handler Class)</a></li>
</ul>
<p><!-- Similar Posts took 3.562 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kavoir.com/2010/07/javascript-how-to-set-focus-to-form-elements.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript: How to get the URL of the current web page?</title>
		<link>http://www.kavoir.com/2010/07/javascript-how-to-get-the-url-of-the-current-web-page.html</link>
		<comments>http://www.kavoir.com/2010/07/javascript-how-to-get-the-url-of-the-current-web-page.html#comments</comments>
		<pubDate>Wed, 21 Jul 2010 16:16:52 +0000</pubDate>
		<dc:creator>Yang Yang</dc:creator>
				<category><![CDATA[JavaScript Tips & Tutorials]]></category>

		<guid isPermaLink="false">http://www.kavoir.com/2010/07/javascript-how-to-get-the-url-of-the-current-web-page.html</guid>
		<description><![CDATA[To get the URL address of the current page with JavaScript, simply return the value of window.location.href: document.write(window.location.href); Which is the same with: document.write(location.href); There’s much more you can do with the JavaScript Location Object such as redirecting to another URL. Related Posts: JavaScript: Open or Redirect to Another Page / Site / Location PHP, [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>To get the URL address of the current page with JavaScript, simply return the value of window.location.href:</p>

<pre><code>document.write(<strong>window.location.href</strong>);</code></pre>
<p>Which is the same with:</p>
<pre><code>document.write(<strong>location.href</strong>);</code></pre>
<p>There’s much more you can do with the <a href="http://www.comptechdoc.org/independent/web/cgi/javamanual/javalocation.html">JavaScript Location Object</a> such as <a href="http://www.kavoir.com/2009/06/javascript-open-or-redirect-to-another-page-site-location.html">redirecting to another URL</a>.</p>
<h3>Related Posts:</h3>
<ul class="similar-posts">
<li><a href="http://www.kavoir.com/2009/06/javascript-open-or-redirect-to-another-page-site-location.html" rel="bookmark" title="June 16, 2009">JavaScript: Open or Redirect to Another Page / Site / Location</a></li>
<li><a href="http://www.kavoir.com/2009/08/javascript-stop-and-prevent-others-from-framing-your-site-and-page.html" rel="bookmark" title="August 30, 2009">PHP, JavaScript: Stop and prevent others from framing your site or web page</a></li>
<li><a href="http://www.kavoir.com/2009/09/how-to-redirect-the-visitor-to-another-page-or-website.html" rel="bookmark" title="September 3, 2009">How to redirect the visitor to another page or website?</a></li>
<li><a href="http://www.kavoir.com/2007/09/portable-functions-for-manipulating-browser-window.html" rel="bookmark" title="September 25, 2007">JavaScript: Changing Browser Window Width / Height</a></li>
<li><a href="http://www.kavoir.com/2009/09/best-way-to-hide-and-cloak-your-affiliate-links.html" rel="bookmark" title="September 19, 2009">Best way to hide and cloak your affiliate links?</a></li>
</ul>
<p><!-- Similar Posts took 2.465 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kavoir.com/2010/07/javascript-how-to-get-the-url-of-the-current-web-page.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP and JavaScript Variable / Value Transfer / Exchange: How to pass variable values from PHP to JavaScript or JavaScript to PHP?</title>
		<link>http://www.kavoir.com/2010/07/php-and-javascript-variable-value-transfer-exchange-how-to-pass-variable-values-from-php-to-javascript-or-javascript-to-php.html</link>
		<comments>http://www.kavoir.com/2010/07/php-and-javascript-variable-value-transfer-exchange-how-to-pass-variable-values-from-php-to-javascript-or-javascript-to-php.html#comments</comments>
		<pubDate>Fri, 09 Jul 2010 04:02:20 +0000</pubDate>
		<dc:creator>Yang Yang</dc:creator>
				<category><![CDATA[JavaScript Tips & Tutorials]]></category>
		<category><![CDATA[PHP Tips & Tutorials]]></category>

		<guid isPermaLink="false">http://www.kavoir.com/2010/07/php-and-javascript-variable-value-transfer-exchange-how-to-pass-variable-values-from-php-to-javascript-or-javascript-to-php.html</guid>
		<description><![CDATA[This is a rather common problem for novice web developers. While it may seem at first glance that it&#8217;s easy for PHP and JavaScript to communicate with each other, but they actually cannot interact with each other directly. They are very different technologies built for distinct purposes. How to transfer or pass variable values from [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>This is a rather common problem for novice web developers. While it may seem at first glance that it&#8217;s easy for PHP and JavaScript to communicate with each other, but they actually cannot interact with each other directly. They are very different technologies built for distinct purposes. </p>

<h3>How to transfer or pass variable values from PHP to JavaScript?</h3>
<p>To pass variables or values from PHP to JavaScript, just write the PHP code to generate the client side JavaScript code as you would with HTML code:</p>
<pre><code>&lt;script&gt;
var jsVar = &quot;<strong>&lt;?php echo $phpVar ?&gt;</strong>&quot;;
&lt;/script&gt;</code></pre>
<p>To embed PHP code in *.js files you have to first make the server to <a href="http://www.kavoir.com/2010/07/how-to-execute-run-php-code-inside-javascript-files.html">parse JavaScript .js files for any PHP code</a> so that they will be executed. After that, you can create classes or call to functions or do whatever that is allowed in PHP in the .js files just as you can with .php files.</p>
<h3>How to transfer or pass variable values from JavaScript to PHP?</h3>
<p>Simply put, you have no other way to let some PHP script know any variable value than to send a request to it. So, you will use JavaScript to send a request to the PHP script by a GET or POST request that bears the variable value.</p>
<p>You can trigger a redirection to the PHP script and pass the values via URL:</p>
<pre><code>var age = 24;
document.location = 'http://www.example.com/script.php?age=' + age;</code></pre>
<p>Or you can perform an <a href="http://www.quirksmode.org/js/xmlhttp.html">XMLHttpRequest request</a> by GET or by POST. </p>
<h3>Related Posts:</h3>
<ul class="similar-posts">
<li><a href="http://www.kavoir.com/2010/03/php-how-to-distinguish-values-in-_post-or-_get-that-are-sent-via-http-requests-and-those-that-are-set-assigned-in-the-code.html" rel="bookmark" title="March 4, 2010">PHP: How to distinguish values in $_POST or $_GET that are sent via HTTP requests and those that are set / assigned in the code</a></li>
<li><a href="http://www.kavoir.com/2010/07/how-to-execute-run-php-code-inside-javascript-files.html" rel="bookmark" title="July 9, 2010">How to execute / run PHP code inside JavaScript files?</a></li>
<li><a href="http://www.kavoir.com/2009/01/how-to-pass-variable-values-in-url-from-page-to-page-with-php.html" rel="bookmark" title="January 5, 2009">How to pass variable values in URL from page to page with PHP?</a></li>
<li><a href="http://www.kavoir.com/2010/07/how-to-include-a-javascript-file-inside-a-javascript-file.html" rel="bookmark" title="July 22, 2010">How to include a JavaScript file inside a JavaScript file?</a></li>
<li><a href="http://www.kavoir.com/2009/06/php-run-css-files-as-php.html" rel="bookmark" title="June 9, 2009">PHP: Run .CSS files as PHP</a></li>
</ul>
<p><!-- Similar Posts took 2.549 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kavoir.com/2010/07/php-and-javascript-variable-value-transfer-exchange-how-to-pass-variable-values-from-php-to-javascript-or-javascript-to-php.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to execute / run PHP code inside JavaScript files?</title>
		<link>http://www.kavoir.com/2010/07/how-to-execute-run-php-code-inside-javascript-files.html</link>
		<comments>http://www.kavoir.com/2010/07/how-to-execute-run-php-code-inside-javascript-files.html#comments</comments>
		<pubDate>Fri, 09 Jul 2010 03:26:36 +0000</pubDate>
		<dc:creator>Yang Yang</dc:creator>
				<category><![CDATA[JavaScript Tips & Tutorials]]></category>
		<category><![CDATA[PHP Tips & Tutorials]]></category>

		<guid isPermaLink="false">http://www.kavoir.com/2010/07/how-to-execute-run-php-code-inside-javascript-files.html</guid>
		<description><![CDATA[Static files of JavaScript would survive most applications but sometimes the ability to include PHP code inside JavaScript scripts and generate the content of the script files on the fly by PHP is a better option. How does one do that? The simplest solution is to just include PHP code inside the &#60;script&#62;&#60;/script&#62; section of [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Static files of JavaScript would survive most applications but sometimes the ability to include PHP code inside JavaScript scripts and generate the content of the script files on the fly by PHP is a better option. How does one do that?</p>

<p>The simplest solution is to just include PHP code inside the &lt;script&gt;&lt;/script&gt; section of your HTML templates / web pages because chances are, the file extension is <strong>.php</strong>:</p>
<pre><code>&lt;script&gt;
var jsVar = &quot;<strong>&lt;?php echo $phpVar ?&gt;</strong>&quot;;
&lt;/script&gt;</code></pre>
<p>Even if it’s not ending in .php, such as in .html or .htm, you can configure your server to <a href="http://www.kavoir.com/2009/01/php-run-html-as-php.html">parse all .html or .htm files for any PHP code</a>, though with a little extra server burden.</p>
<p>Another solution for this is to make your server parse all files ending in <strong>.js</strong>. Just create a <strong>.htaccess </strong>if it doesn’t exist in the directory in which you wish to include and run PHP code inside all .js files. Add these lines at the end of .htaccess:</p>
<pre><code>AddType application/x-httpd-php .js
AddHandler x-httpd-php5 .js

&lt;FilesMatch &quot;\.(js|php)$&quot;&gt;
SetHandler application/x-httpd-php
&lt;/FilesMatch&gt;</code></pre>
<p>Now you can add all the PHP code you can inside any JavaScript files with a .js extension, the server will automatically parse and run them when the client side requests the file.</p>
<h3>Related Posts:</h3>
<ul class="similar-posts">
<li><a href="http://www.kavoir.com/2009/01/php-run-html-as-php.html" rel="bookmark" title="January 19, 2009">PHP: Run HTML as PHP</a></li>
<li><a href="http://www.kavoir.com/2010/07/how-to-include-a-javascript-file-inside-a-javascript-file.html" rel="bookmark" title="July 22, 2010">How to include a JavaScript file inside a JavaScript file?</a></li>
<li><a href="http://www.kavoir.com/2009/06/php-run-css-files-as-php.html" rel="bookmark" title="June 9, 2009">PHP: Run .CSS files as PHP</a></li>
<li><a href="http://www.kavoir.com/2010/07/php-and-javascript-variable-value-transfer-exchange-how-to-pass-variable-values-from-php-to-javascript-or-javascript-to-php.html" rel="bookmark" title="July 9, 2010">PHP and JavaScript Variable / Value Transfer / Exchange: How to pass variable values from PHP to JavaScript or JavaScript to PHP?</a></li>
<li><a href="http://www.kavoir.com/2010/02/use-php-to-handle-all-incoming-url-requests-in-a-seo-friendly-manner.html" rel="bookmark" title="February 23, 2010">Use PHP to handle all incoming URL requests in a SEO friendly manner</a></li>
</ul>
<p><!-- Similar Posts took 3.766 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kavoir.com/2010/07/how-to-execute-run-php-code-inside-javascript-files.html/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>JavaScript: Confirmation / Warning before Leaving or Navigating Away from a Page</title>
		<link>http://www.kavoir.com/2010/04/javascript-confirmation-warning-before-leaving-or-navigating-away-from-a-page.html</link>
		<comments>http://www.kavoir.com/2010/04/javascript-confirmation-warning-before-leaving-or-navigating-away-from-a-page.html#comments</comments>
		<pubDate>Tue, 27 Apr 2010 02:00:40 +0000</pubDate>
		<dc:creator>Yang Yang</dc:creator>
				<category><![CDATA[JavaScript Tips & Tutorials]]></category>

		<guid isPermaLink="false">http://www.kavoir.com/2010/04/javascript-confirmation-warning-before-leaving-or-navigating-away-from-a-page.html</guid>
		<description><![CDATA[Things couldn’t be worse when you were half way editing something and accidentally navigated away from the editing page after a whole hour of typing work. Hitting the back button of your browser neither helped, all you had done was gone anyway. This must be remedied in some way, if you are creating an application [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Things couldn’t be worse when you were half way editing something and accidentally navigated away from the editing page after a whole hour of typing work. Hitting the back button of your browser neither helped, all you had done was gone anyway.</p>

<p>This must be remedied in some way, if you are creating an application that needs the user to input stuff, especially lengthy articles. One approach is to automate draft saving every a few minutes, the other is to warn the user before he or she either intentionally or inadvertently navigate away from the editor page. You can achieve this by a straightforward snippet of JavaScript:</p>
<pre><code>var warning = false;
window.<strong>onbeforeunload</strong> = function() {
  if (warning) {
    return 'You have unsaved changes.';
  }
}</code></pre>
<p>The warning variable can be timely altered according to the editing activities by the user. For instance, it is set true if the editing field is changed or does not equal to default value, or if the user triggers the onKeyUp / onChange event of any input fields:</p>
<pre><code>var editor_form = document.getElementById("form_id");
for (var i = 0; i < editor_form.length; i++) {
	editor_form[i].onchange = function() {
		warning = true;
	}
}</code></pre>
<p>This snippet must be put at the end of the page. Also, to avoid the warning when you press the form submit button, add this snippet after that:</p>
<pre><code>document.getElementById("submit_button_id").onclick = function() {
    warning = false;
}</code></pre>
<h3>Related Posts:</h3>
<ul class="similar-posts">
<li><a href="http://www.kavoir.com/2010/07/javascript-how-to-set-focus-to-form-elements.html" rel="bookmark" title="July 22, 2010">JavaScript: How to set focus to form elements?</a></li>
<li><a href="http://www.kavoir.com/2009/08/javascript-stop-and-prevent-others-from-framing-your-site-and-page.html" rel="bookmark" title="August 30, 2009">PHP, JavaScript: Stop and prevent others from framing your site or web page</a></li>
<li><a href="http://www.kavoir.com/2010/03/php-setcookie-with-httponly-option-to-prevent-xss-cross-site-scripting-attacks.html" rel="bookmark" title="March 4, 2010">PHP: setcookie() with HttpOnly Option to Reduce XSS (Cross Site Scripting) Attacks by Preventing JavaScript from Reading Cookies</a></li>
<li><a href="http://www.kavoir.com/2009/04/php-curl-making-post-request-to-url.html" rel="bookmark" title="April 22, 2009">PHP cURL: Making POST Request to URL</a></li>
<li><a href="http://www.kavoir.com/2011/12/javascript-load-image-based-on-select-option.html" rel="bookmark" title="December 25, 2011">JavaScript: Load Image based on Select Option (Dropdown)</a></li>
</ul>
<p><!-- Similar Posts took 3.307 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kavoir.com/2010/04/javascript-confirmation-warning-before-leaving-or-navigating-away-from-a-page.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to define multiple CSS rules / properties in jQuery?</title>
		<link>http://www.kavoir.com/2010/03/how-to-define-multiple-css-rules-properties-in-jquery.html</link>
		<comments>http://www.kavoir.com/2010/03/how-to-define-multiple-css-rules-properties-in-jquery.html#comments</comments>
		<pubDate>Wed, 03 Mar 2010 14:21:36 +0000</pubDate>
		<dc:creator>Yang Yang</dc:creator>
				<category><![CDATA[JavaScript Tips & Tutorials]]></category>
		<category><![CDATA[jQuery Tips & FAQ]]></category>

		<guid isPermaLink="false">http://www.kavoir.com/2010/03/how-to-define-multiple-css-rules-properties-in-jquery.html</guid>
		<description><![CDATA[The simplest way to define a CSS rule in jQuery might be: $(&#34;.sth&#34;).css(&#34;color&#34;, &#34;#f00&#34;); To define more than one CSS rule in a single jQuery line: $(&#34;.sth&#34;).css(&#34;color&#34;, &#34;#f00&#34;).css(&#34;font-style&#34;, &#34;italic&#34;).css(&#34;text-decoration&#34;, &#34;underline&#34;); Which simply doesn&#8217;t look that good, especially if you intend to add more. A better way to specify multiple CSS rules or properties with jQuery [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>The simplest way to define a CSS rule in jQuery might be:</p>

<pre><code>$(&quot;.sth&quot;).<strong>css</strong>(&quot;color&quot;, &quot;#f00&quot;);</code></pre>
<p>To define more than one CSS rule in a single jQuery line:</p>
<pre><code>$(&quot;.sth&quot;).<strong>css</strong>(&quot;color&quot;, &quot;#f00&quot;).<strong>css</strong>(&quot;font-style&quot;, &quot;italic&quot;).<strong>css</strong>(&quot;text-decoration&quot;, &quot;underline&quot;);</code></pre>
<p>Which simply doesn&#8217;t look that good, especially if you intend to add more. A better way to specify multiple CSS rules or properties with jQuery is by a JSON object:</p>
<pre><code>$(&quot;.sth&quot;).css( <strong>{'color' : '#f00', 'font-style' : 'italic', 'text-decoration' : 'underline'}</strong> );</code></pre>
<p>However, it is recommended that you use .<strong>addClass</strong>() instead of .<strong>css</strong>() to separate the JavaScript logics and CSS styles for maintainability.</p>
<h3>Related Posts:</h3>
<ul class="similar-posts">
<li><a href="http://www.kavoir.com/2009/06/html-change-text-and-font-colors.html" rel="bookmark" title="June 16, 2009">HTML: Change Text and Font Colors</a></li>
<li><a href="http://www.kavoir.com/2009/08/how-to-create-blinking-text-in-html.html" rel="bookmark" title="August 4, 2009">How to Create Blinking Text in HTML</a></li>
<li><a href="http://www.kavoir.com/2009/04/php-gd-library-drawing-functions-reference.html" rel="bookmark" title="April 22, 2009">PHP: GD Library Drawing Functions Reference</a></li>
<li><a href="http://www.kavoir.com/2012/01/customize-wordpress-post-editor-css-styles.html" rel="bookmark" title="January 19, 2012">Customize WordPress Post Editor CSS Styles</a></li>
<li><a href="http://www.kavoir.com/2009/03/styling-an-alphabet-of-26-letters-in-html-and-css.html" rel="bookmark" title="March 5, 2009">Styling an Alphabet of 26 Letters in HTML and CSS</a></li>
</ul>
<p><!-- Similar Posts took 4.248 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kavoir.com/2010/03/how-to-define-multiple-css-rules-properties-in-jquery.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to redirect the visitor to another page or website?</title>
		<link>http://www.kavoir.com/2009/09/how-to-redirect-the-visitor-to-another-page-or-website.html</link>
		<comments>http://www.kavoir.com/2009/09/how-to-redirect-the-visitor-to-another-page-or-website.html#comments</comments>
		<pubDate>Thu, 03 Sep 2009 07:24:24 +0000</pubDate>
		<dc:creator>Yang Yang</dc:creator>
				<category><![CDATA[CSS & HTML Tips]]></category>
		<category><![CDATA[JavaScript Tips & Tutorials]]></category>
		<category><![CDATA[PHP Tips & Tutorials]]></category>

		<guid isPermaLink="false">http://www.kavoir.com/2009/09/how-to-redirect-the-visitor-to-another-page-or-website.html</guid>
		<description><![CDATA[This is one of the most common tasks in website development and also one of the most frequently asked question according to some of the keyword research tools. Well, you have 3 ways to achieve a web page redirection. Use PHP header() function to modify and send a HTTP Location header: header(&#34;Location: /thankyou.html&#34;); // redirect [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>This is one of the most common tasks in website development and also one of the most frequently asked question according to some of the keyword research tools. Well, you have 3 ways to achieve a web page redirection. </p>

<ol>
<li>Use PHP <strong>header</strong>() function to modify and send a HTTP <strong>Location</strong> header:       </p>
<p><code><strong>header</strong>(&quot;Location: /thankyou.html&quot;); // redirect the visitor to the /thankyou.html page on the same website</code>       </p>
<p><code><strong>header</strong>(&quot;Location: http://www.microsoft.com&quot;); // redirect the visitor to Microsoft         </p>
<p></code>You will need to make sure there&#8217;s no output at all before the calling of the header function to avoid any <a href="http://www.kavoir.com/2008/05/warning-session_start-cannot-send-session-cookie-headers-already-sent.html">headers already sent errors</a>. </li>
<li>Use the meta tag of HTML:
<p><code>&lt;<strong>meta</strong> http-equiv=&quot;<strong>refresh</strong>&quot; content=&quot;3;<strong>url</strong>=http://www.example.com/hi.html&quot;&gt;</code>       </p>
<p>Which will simply refresh the visitor&#8217;s browser window and redirect to http://www.example.com/hi.html in 3 seconds. </li>
<li>Use JavaScript to manipulate the browser window location object:
<p><code>&lt;body <strong>onload</strong>=&quot;document.<strong>location</strong>='http://www.example.com/'&quot;&gt;</code> </li>
</ol>
<h3>Related Posts:</h3>
<ul class="similar-posts">
<li><a href="http://www.kavoir.com/2011/08/html-make-a-page-refresh-every-xx-seconds.html" rel="bookmark" title="August 28, 2011">HTML: Make a Page Refresh Every xx Seconds</a></li>
<li><a href="http://www.kavoir.com/2011/12/redirect-404-error-to-home-page.html" rel="bookmark" title="December 25, 2011">Redirect 404 Error to Home Page</a></li>
<li><a href="http://www.kavoir.com/2009/08/javascript-stop-and-prevent-others-from-framing-your-site-and-page.html" rel="bookmark" title="August 30, 2009">PHP, JavaScript: Stop and prevent others from framing your site or web page</a></li>
<li><a href="http://www.kavoir.com/2009/06/javascript-open-or-redirect-to-another-page-site-location.html" rel="bookmark" title="June 16, 2009">JavaScript: Open or Redirect to Another Page / Site / Location</a></li>
<li><a href="http://www.kavoir.com/2009/09/best-way-to-hide-and-cloak-your-affiliate-links.html" rel="bookmark" title="September 19, 2009">Best way to hide and cloak your affiliate links?</a></li>
</ul>
<p><!-- Similar Posts took 2.847 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kavoir.com/2009/09/how-to-redirect-the-visitor-to-another-page-or-website.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP, JavaScript: Stop and prevent others from framing your site or web page</title>
		<link>http://www.kavoir.com/2009/08/javascript-stop-and-prevent-others-from-framing-your-site-and-page.html</link>
		<comments>http://www.kavoir.com/2009/08/javascript-stop-and-prevent-others-from-framing-your-site-and-page.html#comments</comments>
		<pubDate>Sun, 30 Aug 2009 02:05:17 +0000</pubDate>
		<dc:creator>Yang Yang</dc:creator>
				<category><![CDATA[JavaScript Tips & Tutorials]]></category>
		<category><![CDATA[PHP Tips & Tutorials]]></category>

		<guid isPermaLink="false">http://www.kavoir.com/2009/08/javascript-stop-and-prevent-others-from-framing-your-site-and-page.html</guid>
		<description><![CDATA[Though it does increase traffic and the pageviews, it doesn’t feel quite good with someone who’s loading your website or page as a part of theirs in the form of a &#60;frame&#62; or &#60;iframe&#62;, leeching your content as part of theirs. To prevent them from loading your pages this way, and make the visitor browser [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Though it does increase traffic and the pageviews, it doesn’t feel quite good with someone who’s loading your website or page as a part of theirs in the form of a &lt;frame&gt; or &lt;iframe&gt;, leeching your content as part of theirs. To prevent them from loading your pages this way, and make the visitor browser to load the entire window with your site on the &quot;_top&quot; level, you need some javascript:</p>

<pre><code>&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
	if (self.location.href != top.location.href) {
		top.location.href = self.location.href;
	}
// --&gt;
&lt;/script&gt;</code></pre>
<p>Basically, this snippet checks if the URL location of this frame is the same with that of the top frame that is the browser window, if negative, meaning your site or page is being framed from another site, the entire window is then loading your site as the only page.</p>
<p>On the other hand, you can also do this by the help of PHP or a combination of both. Just check the global variable <strong>$_SERVER['HTTP_REFERER']</strong> against the URL of a particular leeching site, if it’s a match, stop serving the content and redirect the visitors to a warning page so that they know they can come to your website directly instead of from a frame or iframe:</p>
<pre><code>if (<strong>strpos</strong>($_SERVER['HTTP_REFERER'], 'leechsite.com') !== false) { // if a match
	<strong>header</strong>(&quot;Location: /warning.html&quot;); // redirect to /warning.html
	exit();
}</code></pre>
<p>Pretty much the simplest solution to this.</p>
<p><strong><span style="color:green;">Interesting: </span></strong>Make sure you give a read to <a href="http://stackoverflow.com/questions/958997/frame-buster-buster-buster-code-needed">this Q&#038;A thread</a> at Stack Overflow.</p>
<h3>Related Posts:</h3>
<ul class="similar-posts">
<li><a href="http://www.kavoir.com/2009/06/javascript-open-or-redirect-to-another-page-site-location.html" rel="bookmark" title="June 16, 2009">JavaScript: Open or Redirect to Another Page / Site / Location</a></li>
<li><a href="http://www.kavoir.com/2009/09/how-to-redirect-the-visitor-to-another-page-or-website.html" rel="bookmark" title="September 3, 2009">How to redirect the visitor to another page or website?</a></li>
<li><a href="http://www.kavoir.com/2010/07/javascript-how-to-get-the-url-of-the-current-web-page.html" rel="bookmark" title="July 22, 2010">JavaScript: How to get the URL of the current web page?</a></li>
<li><a href="http://www.kavoir.com/2011/12/redirect-404-error-to-home-page.html" rel="bookmark" title="December 25, 2011">Redirect 404 Error to Home Page</a></li>
<li><a href="http://www.kavoir.com/2009/09/best-way-to-hide-and-cloak-your-affiliate-links.html" rel="bookmark" title="September 19, 2009">Best way to hide and cloak your affiliate links?</a></li>
</ul>
<p><!-- Similar Posts took 4.723 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kavoir.com/2009/08/javascript-stop-and-prevent-others-from-framing-your-site-and-page.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to change the browser window status bar text of Firefox with JavaScript?</title>
		<link>http://www.kavoir.com/2009/08/how-to-change-the-browser-window-status-bar-text-of-firefox-with-javascript.html</link>
		<comments>http://www.kavoir.com/2009/08/how-to-change-the-browser-window-status-bar-text-of-firefox-with-javascript.html#comments</comments>
		<pubDate>Sat, 22 Aug 2009 04:15:30 +0000</pubDate>
		<dc:creator>Yang Yang</dc:creator>
				<category><![CDATA[JavaScript Tips & Tutorials]]></category>

		<guid isPermaLink="false">http://www.kavoir.com/2009/08/how-to-change-the-browser-window-status-bar-text-of-firefox-with-javascript.html</guid>
		<description><![CDATA[It’s strange that you can accomplish this in IE while you can’t make it happen in Firefox. Well, that’s because the development team has decided that it’s potentially annoying and harmful for web developers to change the text of Firefox status bar whatever way they want. So the simple answer is, you can’t. But there’s [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>It’s strange that you can accomplish this in IE while you can’t make it happen in Firefox. Well, that’s because the development team has decided that it’s potentially annoying and harmful for web developers to change the text of Firefox status bar whatever way they want.</p>

<p>So the simple answer is, you can’t. But there’s always some sort of switch that would turn on or off the custom modification of the status bar text.</p>
<p>Simply type <strong>about:config</strong> in the Firefox address bar and it would take you to a vault of hidden advanced settings not meant for common users. Filter: <strong>disable_window_status_change</strong> and you will see that Firefox has come disabled of window status change by default.</p>
<p><img title="firefox window status change" src="http://www.kavoir.com/wp-content/uploads/2009/08/firefoxwindowstatuschange.gif" alt="firefox window status change" /></p>
<p>You can switch it off by changing the Value to <strong>false</strong>. However that ain&#8217;t gonna help you much because the vast majority of other Firefox users have left it in default, thus the JavaScript trick won&#8217;t work on their browsers.<br />
<h3>Related Posts:</h3>
<ul class="similar-posts">
<li><a href="http://www.kavoir.com/2009/04/how-to-disable-or-enable-a-form-element-with-jquery.html" rel="bookmark" title="April 16, 2009">How to disable or enable a form element with jQuery?</a></li>
<li><a href="http://www.kavoir.com/2011/09/3-tips-for-zend-studio-8-eclipse.html" rel="bookmark" title="September 14, 2011">4 Tips for Zend Studio 8 (Eclipse)</a></li>
<li><a href="http://www.kavoir.com/2009/11/how-to-recover-lost-firefox-bookmarks-where-is-my-firefox-bookmarks-folder.html" rel="bookmark" title="November 12, 2009">How to recover lost Firefox bookmarks? Where is my Firefox bookmarks folder?</a></li>
<li><a href="http://www.kavoir.com/2010/06/how-to-enable-change-vbulletin-default-thread-subscription-mode-for-new-user-registrations.html" rel="bookmark" title="June 14, 2010">How to Enable / Change vBulletin Default Thread Subscription Mode for New User Registrations?</a></li>
<li><a href="http://www.kavoir.com/2009/04/phpbb-disabling-user-registrations-signup.html" rel="bookmark" title="April 18, 2009">phpBB: Disabling User Registrations / Signup</a></li>
</ul>
<p><!-- Similar Posts took 4.398 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kavoir.com/2009/08/how-to-change-the-browser-window-status-bar-text-of-firefox-with-javascript.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Best JavaScript Books for Learning JavaScript Programming and Development</title>
		<link>http://www.kavoir.com/2009/06/best-javascript-books-for-learning-javascript-programming-and-development.html</link>
		<comments>http://www.kavoir.com/2009/06/best-javascript-books-for-learning-javascript-programming-and-development.html#comments</comments>
		<pubDate>Wed, 17 Jun 2009 04:22:24 +0000</pubDate>
		<dc:creator>Yang Yang</dc:creator>
				<category><![CDATA[Client Side Coding Books]]></category>
		<category><![CDATA[JavaScript Tips & Tutorials]]></category>

		<guid isPermaLink="false">http://www.kavoir.com/2009/06/best-javascript-books-for-learning-javascript-programming-and-development.html</guid>
		<description><![CDATA[Thanks to the computer scientists who set the standards of JavaScript, in the arena of event programming and behavioral manipulations of windows and objects, it is the one programming script that is so powerful that you can virtually build any possible interactive applications with it. That said, learning JavaScript to the mastery of it takes [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Thanks to the computer scientists who set the standards of JavaScript, in the arena of event programming and behavioral manipulations of windows and objects, it is the one programming script that is so powerful that you can virtually build any possible interactive applications with it.</p>

<p>That said, learning JavaScript to the mastery of it takes lots of time and practice. These are some JavaScript books I have selected from Amazon that may be a good guide to you when you are learning JavaScript front end programming.</p>
<h4>Web Developers / Designers&#8217; Books:</h4>
<ol>
<li><a href="http://www.kavoir.com/2009/06/best-books-of-html-and-xhtml-to-learn-how-to-create-web-pages-sites-with-html-and-css.html">Best HTML Books</a></li>
<li><a href="http://www.kavoir.com/2009/06/best-css-books-to-learn-css-web-design.html">Best CSS Books</a></li>
<li><a href="http://www.kavoir.com/2009/06/best-javascript-books-for-learning-javascript-programming-and-development.html">Best JavaScript Books</a></li>
<li><a href="http://www.kavoir.com/2009/06/best-php-books-for-learning-php-and-mysql.html">Best PHP Books</a></li>
<li><a href="http://www.kavoir.com/2009/06/best-mysql-books-to-learn-mysql-database-php-applications.html">Best MySQL Books</a></li>
<li><a href="http://www.shanghaiwebhosting.com/web-hosting-tutorials/best-linux-server-administration-books-for-learning-linux">Best Linux Books</a></li>
<li><a href="http://www.kavoir.com/2009/06/best-books-of-apache-web-server-to-learn-apache-and-use-it.html">Best Apache Books</a> (<a href="http://www.shanghaiwebhosting.com/web-hosting-tips/best-books-about-apache-mod_rewrite-module-htaccess-books">mod_rewrite Books</a>)</li>
<li><a href="http://www.shanghaiwebhosting.com/web-hosting-tutorials/best-web-hosting-books-to-learn-about-web-hosting">Best Web Hosting Books</a></li>
</ol>
<h3><a href="http://www.amazon.com/gp/product/0596517742?ie=UTF8&#038;tag=maawe-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0596517742">JavaScript: The Good Parts</a></h3>
<p><a href="http://www.amazon.com/gp/product/0596517742?ie=UTF8&#038;tag=maawe-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0596517742"><img title="JavaScript: The Good Parts" alt="JavaScript: The Good Parts" src="http://www.kavoir.com/wp-content/uploads/2009/06/JavaScript-The-Good-Parts.jpg" width="300" /></a> </p>
<h3><a href="http://www.amazon.com/gp/product/0596101996?ie=UTF8&amp;tag=maawe-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0596101996">JavaScript: The Definitive Guide</a></h3>
<p><a href="http://www.amazon.com/gp/product/0596101996?ie=UTF8&amp;tag=maawe-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0596101996"><img title="JavaScript The Definitive Guide" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="375" alt="JavaScript The Definitive Guide" src="http://www.kavoir.com/wp-content/uploads/2009/06/JavaScriptTheDefinitiveGuide.jpg" width="300" border="0" /></a> </p>
<h3><a href="http://www.amazon.com/gp/product/047022780X?ie=UTF8&amp;tag=maawe-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=047022780X">Professional JavaScript for Web Developers (Wrox Programmer to Programmer)</a></h3>
<p><a href="http://www.amazon.com/gp/product/047022780X?ie=UTF8&amp;tag=maawe-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=047022780X"><img title="Professional JavaScript for Web Developers (Wrox Programmer to Programmer)" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="353" alt="Professional JavaScript for Web Developers (Wrox Programmer to Programmer)" src="http://www.kavoir.com/wp-content/uploads/2009/06/ProfessionalJavaScriptforWebDevelopersWroxProgrammertoProgrammer.jpg" width="300" border="0" /></a> </p>
<h3><a href="http://www.amazon.com/gp/product/0072227907?ie=UTF8&amp;tag=maawe-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0072227907">JavaScript: A Beginner&#8217;s Guide, Second Edition</a>, <a href="http://www.amazon.com/gp/product/0071632956?ie=UTF8&#038;tag=maawe-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0071632956">Third Edition</a></h3>
<p><a href="http://www.amazon.com/gp/product/0072227907?ie=UTF8&amp;tag=maawe-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0072227907"><img title="JavaScript A Beginner&#39;s Guide, Second Edition" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="362" alt="JavaScript A Beginner&#39;s Guide, Second Edition" src="http://www.kavoir.com/wp-content/uploads/2009/06/JavaScriptABeginnersGuideSecondEdition.jpg" width="300" border="0" /></a> </p>
<h3><a href="http://www.amazon.com/gp/product/1890774553?ie=UTF8&#038;tag=maawe-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=1890774553">Murach&#8217;s JavaScript and DOM Scripting (Murach: Training &#038; Reference)</a></h3>
<p><a href="http://www.amazon.com/gp/product/1890774553?ie=UTF8&#038;tag=maawe-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=1890774553"><img title="Murach's JavaScript and DOM Scripting (Murach: Training &#038; Reference)" alt="Murach's JavaScript and DOM Scripting (Murach: Training &#038; Reference)" src="http://www.kavoir.com/wp-content/uploads/2009/06/Murachs-JavaScript-and-DOM-Scripting-Murach-Training-Reference.jpg" width="300" /></a> </p>
<h3><a href="http://www.amazon.com/gp/product/0735624496?ie=UTF8&amp;tag=maawe-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0735624496">JavaScript(TM) Step by Step</a></h3>
<p><a href="http://www.amazon.com/gp/product/0735624496?ie=UTF8&amp;tag=maawe-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0735624496"><img title="JavaScript(TM) Step by Step" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="351" alt="JavaScript(TM) Step by Step" src="http://www.kavoir.com/wp-content/uploads/2009/06/JavaScriptTMStepbyStep.jpg" width="300" border="0" /></a>&#160;</p>
<h3><a href="http://www.amazon.com/gp/product/1590597273?ie=UTF8&amp;tag=maawe-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1590597273">Pro JavaScript Techniques</a></h3>
<p><a href="http://www.amazon.com/gp/product/1590597273?ie=UTF8&amp;tag=maawe-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1590597273"><img title="Pro JavaScript Techniques" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="383" alt="Pro JavaScript Techniques" src="http://www.kavoir.com/wp-content/uploads/2009/06/ProJavaScriptTechniques.jpg" width="300" border="0" /></a> </p>
<h3><a href="http://www.amazon.com/gp/product/0596514085?ie=UTF8&amp;tag=maawe-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0596514085">JavaScript &amp; DHTML Cookbook (2nd edition)</a></h3>
<p><a href="http://www.amazon.com/gp/product/0596514085?ie=UTF8&amp;tag=maawe-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0596514085"><img title="JavaScript &amp; DHTML Cookbook (2nd edition)" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="392" alt="JavaScript &amp; DHTML Cookbook (2nd edition)" src="http://www.kavoir.com/wp-content/uploads/2009/06/JavaScriptDHTMLCookbook2ndedition.jpg" width="300" border="0" /></a> </p>
<h3><a href="http://www.amazon.com/gp/product/1847194141?ie=UTF8&amp;tag=maawe-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1847194141">Object-Oriented JavaScript: Create scalable, reusable high-quality JavaScript applications and libraries</a></h3>
<p><a href="http://www.amazon.com/gp/product/1847194141?ie=UTF8&amp;tag=maawe-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1847194141"><img title="Object-Oriented JavaScript Create scalable, reusable high-quality JavaScript applications and libraries" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="341" alt="Object-Oriented JavaScript Create scalable, reusable high-quality JavaScript applications and libraries" src="http://www.kavoir.com/wp-content/uploads/2009/06/ObjectOrientedJavaScriptCreatescalablereusablehighqualityJavaScriptapplicationsandlibraries1.jpg" width="300" border="0" /></a> </p>
<h3><a href="http://www.amazon.com/gp/product/159059908X?ie=UTF8&amp;tag=maawe-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=159059908X">Pro JavaScript Design Patterns (Recipes: a Problem-Solution Ap)</a></h3>
<p><a href="http://www.amazon.com/gp/product/159059908X?ie=UTF8&amp;tag=maawe-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=159059908X"><img title="Pro JavaScript Design Patterns (Recipes a Problem-Solution Ap)" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="383" alt="Pro JavaScript Design Patterns (Recipes a Problem-Solution Ap)" src="http://www.kavoir.com/wp-content/uploads/2009/06/ProJavaScriptDesignPatternsRecipesaProblemSolutionAp.jpg" width="300" border="0" /></a> </p>
<h3><a href="http://www.amazon.com/gp/product/B0000B0SXS?ie=UTF8&amp;tag=maawe-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=B0000B0SXS">Beginning JavaScript</a></h3>
<p><a href="http://www.amazon.com/gp/product/B0000B0SXS?ie=UTF8&amp;tag=maawe-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=B0000B0SXS"><img title="Beginning JavaScript" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="347" alt="Beginning JavaScript" src="http://www.kavoir.com/wp-content/uploads/2009/06/BeginningJavaScript.jpg" width="300" border="0" /></a></p>
<h3>Related Posts:</h3>
<ul class="similar-posts">
<li><a href="http://www.kavoir.com/2009/06/best-php-books-for-learning-php-and-mysql.html" rel="bookmark" title="June 17, 2009">Best PHP Books for Learning PHP Development and Programming (with MySQL)</a></li>
<li><a href="http://www.kavoir.com/2009/06/best-css-books-to-learn-css-web-design.html" rel="bookmark" title="June 17, 2009">Best CSS Books to Learn CSS Web Design</a></li>
<li><a href="http://www.kavoir.com/2010/07/best-and-newest-html-5-books-and-some-css3-books.html" rel="bookmark" title="July 5, 2010">Best and Newest HTML5 Books (and Some CSS3 Books)</a></li>
<li><a href="http://www.kavoir.com/2009/06/best-mysql-books-to-learn-mysql-database-php-applications.html" rel="bookmark" title="June 17, 2009">Best MySQL Books to Learn MySQL Database Programming and Development (+ PHP Applications)</a></li>
<li><a href="http://www.kavoir.com/2009/06/best-books-of-html-and-xhtml-to-learn-how-to-create-web-pages-sites-with-html-and-css.html" rel="bookmark" title="June 17, 2009">Best Books of HTML and XHTML to Learn How to Create Web Pages / Sites with HTML and CSS</a></li>
</ul>
<p><!-- Similar Posts took 3.119 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kavoir.com/2009/06/best-javascript-books-for-learning-javascript-programming-and-development.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>JavaScript: Open or Redirect to Another Page / Site / Location</title>
		<link>http://www.kavoir.com/2009/06/javascript-open-or-redirect-to-another-page-site-location.html</link>
		<comments>http://www.kavoir.com/2009/06/javascript-open-or-redirect-to-another-page-site-location.html#comments</comments>
		<pubDate>Tue, 16 Jun 2009 11:27:02 +0000</pubDate>
		<dc:creator>Yang Yang</dc:creator>
				<category><![CDATA[JavaScript Tips & Tutorials]]></category>

		<guid isPermaLink="false">http://www.kavoir.com/2009/06/javascript-open-or-redirect-to-another-page-site-location.html</guid>
		<description><![CDATA[One of the most common uses of JavaScript is to redirect the user to or automatically open up another web page location. For example, when the user clicks a button, the JavaScript will redirect the user to the location selected in the drop down select menu. It&#8217;s just like the user has typed the web [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>One of the most common uses of JavaScript is to redirect the user to or automatically open up another web page location. For example, when the user clicks a button, the JavaScript will redirect the user to the location selected in the drop down select menu. It&#8217;s just like the user has typed the web page location URL.</p>

<p>There are 2 ways to use JavaScript to navigate to another web page. The first is to rely on the window object:</p>
<pre><code>&lt;script type=&quot;text/javascript&quot;&gt;
	window.<strong>location</strong>=&quot;http://www.bing.com&quot;
&lt;/script&gt;</code></pre>
<p>The location method mimics the user behavior of typing a URL address in the address bar of the browser window. The browser then forwards to that web site, leaving the last web page in the previous entry of browsing history.</p>
<p>The second approach is to use the replace method of location object:</p>
<p><code>location.<strong>replace</strong>(&quot;http://www.microsoft.com&quot;);</code> </p>
<p>This is trickier in that it&#8217;s not like what users would do. Instead of creating a new history entry, this method replaces the old history entry by the new one. Essentially, users cannot go back to the previous page with this approach, the previous web page is replaced by the new one: <a href="http://www.microsoft.com">http://www.microsoft.com</a>.</p>
<h3>Related Posts:</h3>
<ul class="similar-posts">
<li><a href="http://www.kavoir.com/2010/07/javascript-how-to-get-the-url-of-the-current-web-page.html" rel="bookmark" title="July 22, 2010">JavaScript: How to get the URL of the current web page?</a></li>
<li><a href="http://www.kavoir.com/2009/09/how-to-redirect-the-visitor-to-another-page-or-website.html" rel="bookmark" title="September 3, 2009">How to redirect the visitor to another page or website?</a></li>
<li><a href="http://www.kavoir.com/2009/08/javascript-stop-and-prevent-others-from-framing-your-site-and-page.html" rel="bookmark" title="August 30, 2009">PHP, JavaScript: Stop and prevent others from framing your site or web page</a></li>
<li><a href="http://www.kavoir.com/2010/03/php-setcookie-with-httponly-option-to-prevent-xss-cross-site-scripting-attacks.html" rel="bookmark" title="March 4, 2010">PHP: setcookie() with HttpOnly Option to Reduce XSS (Cross Site Scripting) Attacks by Preventing JavaScript from Reading Cookies</a></li>
<li><a href="http://www.kavoir.com/2011/12/redirect-404-error-to-home-page.html" rel="bookmark" title="December 25, 2011">Redirect 404 Error to Home Page</a></li>
</ul>
<p><!-- Similar Posts took 4.609 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kavoir.com/2009/06/javascript-open-or-redirect-to-another-page-site-location.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>JavaScript: Split and Divide Text String by A Delimiter</title>
		<link>http://www.kavoir.com/2009/06/javascript-split-and-divide-text-string-by-a-delimiter.html</link>
		<comments>http://www.kavoir.com/2009/06/javascript-split-and-divide-text-string-by-a-delimiter.html#comments</comments>
		<pubDate>Tue, 16 Jun 2009 11:15:33 +0000</pubDate>
		<dc:creator>Yang Yang</dc:creator>
				<category><![CDATA[JavaScript Tips & Tutorials]]></category>

		<guid isPermaLink="false">http://www.kavoir.com/2009/06/javascript-split-and-divide-text-string-by-a-delimiter.html</guid>
		<description><![CDATA[Spliting and dividing a string into several chunks is a rather basic need for text parsing. You can do it easily in PHP by the help of explode() function or preg_split(), in JavaScript, you can achieve this task by the split() string function. The following example illustrates the usage of javascript split() function to slice [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Spliting and dividing a string into several chunks is a rather basic need for text parsing. You can do it easily in PHP by the help of explode() function or preg_split(), in JavaScript, you can achieve this task by the <strong>split</strong>() string function.</p>

<p>The following example illustrates the usage of javascript split() function to slice a string into various parts in an array.</p>
<pre><code>var str = &quot;How are you&quot;;
var words = str.<strong>split</strong>(&quot; &quot;); //split using a single blank space as the delimiter
for (i = 0; i &lt; words.length; i++) {
	alert(words[i]); //alerts &quot;How&quot;, &quot;are&quot; and &quot;you&quot; sequentially
}</code></pre>
<p>Note that split is a method of string objects in JavaScript, not standalone functions. Therefore, you can even use it this way:</p>
<p><code>var words = &quot;How are you&quot;.<strong>split</strong>(&quot; &quot;);</code><br />
<h3>Related Posts:</h3>
<ul class="similar-posts">
<li><a href="http://www.kavoir.com/2009/04/jquery-how-to-test-or-check-whether-an-element-exists.html" rel="bookmark" title="April 16, 2009">jQuery: How to test or check whether an element exists</a></li>
<li><a href="http://www.kavoir.com/2009/01/php-array-length-function-to-get-length-of-arrays.html" rel="bookmark" title="January 9, 2009">PHP Array Length Function to Get Length of Arrays</a></li>
<li><a href="http://www.kavoir.com/2009/07/php-count-words-in-a-string.html" rel="bookmark" title="July 29, 2009">PHP: Count Words in a String</a></li>
<li><a href="http://www.kavoir.com/2010/09/php-checking-text-strings-against-reserved-or-censored-words.html" rel="bookmark" title="September 27, 2010">PHP: Checking Text Strings against Reserved or Censored Words</a></li>
<li><a href="http://www.kavoir.com/2009/01/php-string-length-function-to-get-length-of-strings-in-php.html" rel="bookmark" title="January 10, 2009">PHP String Length function to Get Length of Strings in PHP</a></li>
</ul>
<p><!-- Similar Posts took 2.666 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kavoir.com/2009/06/javascript-split-and-divide-text-string-by-a-delimiter.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery: Protecting or hiding variables / functions in a specific local scope</title>
		<link>http://www.kavoir.com/2009/04/jquery-protecting-or-hiding-variables-functions-in-a-specific-local-scope.html</link>
		<comments>http://www.kavoir.com/2009/04/jquery-protecting-or-hiding-variables-functions-in-a-specific-local-scope.html#comments</comments>
		<pubDate>Fri, 17 Apr 2009 03:00:35 +0000</pubDate>
		<dc:creator>Yang Yang</dc:creator>
				<category><![CDATA[JavaScript Tips & Tutorials]]></category>
		<category><![CDATA[jQuery Tips & FAQ]]></category>

		<guid isPermaLink="false">http://www.kavoir.com/2009/04/jquery-protecting-or-hiding-variables-functions-in-a-specific-local-scope.html</guid>
		<description><![CDATA[As everyone who’s well trained in software engineering would agree, that one of the principle of writing predictable code is to separate and hide something within only the scope that it’s needed. Controlled access to and from the outside world brings predictability and accountability of your code thus better debugging. In jQuery, you need constantly [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>As everyone who’s well trained in software engineering would agree, that one of the principle of writing predictable code is to separate and hide something within only the scope that it’s needed. Controlled access to and from the outside world brings predictability and accountability of your code thus better debugging.</p>

<p>In jQuery, you need constantly extending the native features by writing extra plugins and adding new functions:</p>
<pre><code>var newMethods = {
  check       : function() { ... },
  uncheck     : function() { ... },
  toggleCheck : function() { ... }
};
jQuery.each(newMethods, function(i) {
  jQuery.fn[i] = this;
});</code></pre>
<p>Without proper fencing, the variable containing 3 functions <strong>newMethods</strong> is everything but protected from the global scope (outside world), increaseing the complexity of the code and difficulty in debugging. To solve this problem, you will want to embrace the code in <strong>an anonymous function</strong>.</p>
<pre><code><strong>(function() {</strong>
  var newMethods = {
    check       : function() { ... },
    uncheck     : function() { ... },
    toggleCheck : function() { ... }
  };
  jQuery.each(newMethods, function(i) {
    jQuery.fn[i] = this;
  });
<strong>})();</strong></code></pre>
<h3>Related Posts:</h3>
<ul class="similar-posts">
<li><a href="http://www.kavoir.com/2009/04/jquery-check-uncheck-form-checkbox-and-radio.html" rel="bookmark" title="April 16, 2009">jQuery: Check / uncheck form checkbox and radio</a></li>
<li><a href="http://www.kavoir.com/2010/09/regular-expression-for-natural-numbers-or-positive-integers-1-2-3-11-12.html" rel="bookmark" title="September 29, 2010">Regular Expressions for Natural Numbers or Positive Integers (1, 2, 3, &hellip;), Negative Integers and Non-negative Integers</a></li>
<li><a href="http://www.kavoir.com/2009/03/incisive-software-engineering-programming-quotes-and-sayings.html" rel="bookmark" title="March 10, 2009">Incisive Software Engineering &amp; Programming Quotes and Sayings</a></li>
<li><a href="http://www.kavoir.com/2009/04/jquery-how-to-check-if-an-element-has-a-particular-class.html" rel="bookmark" title="April 16, 2009">jQuery: How to check if an element has a particular class</a></li>
<li><a href="http://www.kavoir.com/2010/03/how-to-define-multiple-css-rules-properties-in-jquery.html" rel="bookmark" title="March 3, 2010">How to define multiple CSS rules / properties in jQuery?</a></li>
</ul>
<p><!-- Similar Posts took 2.769 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kavoir.com/2009/04/jquery-protecting-or-hiding-variables-functions-in-a-specific-local-scope.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery: Get the text and value of the selected option of HTML select element</title>
		<link>http://www.kavoir.com/2009/04/jquery-get-the-text-and-value-of-the-selected-option-of-html-select-element.html</link>
		<comments>http://www.kavoir.com/2009/04/jquery-get-the-text-and-value-of-the-selected-option-of-html-select-element.html#comments</comments>
		<pubDate>Thu, 16 Apr 2009 15:30:04 +0000</pubDate>
		<dc:creator>Yang Yang</dc:creator>
				<category><![CDATA[JavaScript Tips & Tutorials]]></category>
		<category><![CDATA[jQuery Tips & FAQ]]></category>

		<guid isPermaLink="false">http://www.kavoir.com/2009/04/jquery-get-the-text-and-value-of-the-selected-option-of-html-select-element.html</guid>
		<description><![CDATA[For instance, there’s a HTML select element identified by the ID #title, and after the user has selected one of the options, you want to get the text and value of the selected option. &#60;select id=&#34;title&#34;&#62; &#60;option value=&#34;1&#34;&#62;Mr&#60;/option&#62; &#60;option value=&#34;2&#34;&#62;Mrs&#60;/option&#62; &#60;option value=&#34;3&#34;&#62;Miss&#60;/option&#62; &#60;/select&#62; Now that the user has selected the 2nd option: Mrs. To get [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>For instance, there’s a HTML select element identified by the ID #title, and after the user has selected one of the options, you want to get the text and value of the selected option.</p>

<pre><code>&lt;select id=&quot;title&quot;&gt;
  &lt;option value=&quot;1&quot;&gt;Mr&lt;/option&gt;
  &lt;option value=&quot;2&quot;&gt;Mrs&lt;/option&gt;
  &lt;option value=&quot;3&quot;&gt;Miss&lt;/option&gt;
&lt;/select&gt;</code></pre>
<p>Now that the user has selected the 2nd option: Mrs. To get the value (in this case, ‘2’):</p>
<p><code>$(&quot;select#title&quot;).<strong>val</strong>();</code> </p>
<p>Which is also the common function to return the value of all other form controls.</p>
<p>To get the text of the selected option (in this case, ‘Mrs’):</p>
<p><code>$(&quot;#title option<strong>:selected</strong>&quot;).<strong>text</strong>();</code><br />
<h3>Related Posts:</h3>
<ul class="similar-posts">
<li><a href="http://www.kavoir.com/2009/02/php-drop-down-list.html" rel="bookmark" title="February 8, 2009">PHP: Drop Down List with Select</a></li>
<li><a href="http://www.kavoir.com/2011/12/javascript-load-image-based-on-select-option.html" rel="bookmark" title="December 25, 2011">JavaScript: Load Image based on Select Option (Dropdown)</a></li>
<li><a href="http://www.kavoir.com/2009/08/html-tags-design-for-template-theme-creation.html" rel="bookmark" title="August 27, 2009">HTML Tags Design for Template / Theme Creation</a></li>
<li><a href="http://www.kavoir.com/2010/11/mysql-export-table-to-csv-text-files-for-excel.html" rel="bookmark" title="November 18, 2010">MySQL: Export Table to CSV Text Files for Excel</a></li>
<li><a href="http://www.kavoir.com/2010/02/php-allow-specific-html-tags-in-text-input-controls-of-html-forms-textarea-input-typetext.html" rel="bookmark" title="February 15, 2010">PHP: Allow Specific HTML Tags in Text Input Controls of HTML Forms, &lt;textarea&gt;, &lt;input type=&rdquo;text&rdquo; /&gt;</a></li>
</ul>
<p><!-- Similar Posts took 2.912 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kavoir.com/2009/04/jquery-get-the-text-and-value-of-the-selected-option-of-html-select-element.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

