<?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>Roshan Bhattarai's Blog -  A blog about PHP, Ajax, JavaScript, CSS and Web 2.0 &#187; javascript</title>
	<atom:link href="http://roshanbh.com.np/category/javascript/feed" rel="self" type="application/rss+xml" />
	<link>http://roshanbh.com.np</link>
	<description>Useful Tutorials, Scripts , Tips, and Resources for all PHP and Ajax beginners and experts .</description>
	<lastBuildDate>Thu, 10 Jun 2010 11:38:45 +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>jQuery plugin: word-counter for textarea</title>
		<link>http://roshanbh.com.np/2008/10/jquery-plugin-word-counter-textarea.html</link>
		<comments>http://roshanbh.com.np/2008/10/jquery-plugin-word-counter-textarea.html#comments</comments>
		<pubDate>Mon, 20 Oct 2008 11:43:50 +0000</pubDate>
		<dc:creator>Roshan</dc:creator>
				<category><![CDATA[how-to]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[jquery plugin]]></category>

		<guid isPermaLink="false">http://roshanbh.com.np/?p=299</guid>
		<description><![CDATA[Sorry friends on the way of move to new home I&#8217;ve been lost from the blog as I didn&#8217;t have internet connection for few last weeks. Now, I&#8217;m back and I try to be regular as much as I can. Inspired from the new feature of wordpress 2.6.x which displays word count of each post, [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float:right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F10%2Fjquery-plugin-word-counter-textarea.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F10%2Fjquery-plugin-word-counter-textarea.html&amp;source=roshanbh&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Sorry friends on the way of move to new home I&#8217;ve been lost from the blog as I didn&#8217;t have internet connection for few last weeks. Now, I&#8217;m back and I try to be regular as much as I can. Inspired from the new feature of wordpress 2.6.x which displays word count of each post, I&#8217;ve developed jQuery plugin to display word-count of Textarea. Please note that it is <span style="color: #000080;">word count plugin</span> not <span style="text-decoration: line-through;">character counter</span>.<br />
<span id="more-299"></span><br />
<a href="http://roshanbh.com.np/examples/jquery-word-count-plugin/" target="_blank"><strong>LIVE  DEMO </strong></a></p>
<h4>Jquery plugin: Word-count code</h4>
<pre class="prettyprint" style="overflow:auto">jQuery.fn.wordCount = function(params)
{
   var p =  {
   counterElement:"display_count"
   };
   var total_words;

  if(params) {
      jQuery.extend(p, params);
   }

  //for each keypress function on text areas
  this.keypress(function()
  {
    total_words=this.value.split(/[\s\.\?]+/).length;
    jQuery('#'+p.counterElement).html(total_words);
   });
};</pre>
<p><a href="http://roshanbh.com.np/codes/jquery.wordcount.js" target="_blank"><strong>VIEW PLUGIN&#8217;S CODE</strong></a></p>
<p>As you can in the above code, I assume that each words of a paragraph are separated by the either spaces or dots(.) . Please have your suggestion if i can more characters to improve this plugin.</p>
<h4>How to use this plugin?</h4>
<p>Well, you can guess that a Textarea is needed of whose words are counted and another element like div or span needed to display the word count.</p>
<p>For example, the below HTML code contains Textarea (whose total word is counted) and span (for displaying counted word).</p>
<pre class="prettyprint" style="overflow:auto">&lt;textarea name="word_count" id="word_count" cols="30" rows="6"&gt;&lt;/textarea&gt;
Total word Count : &lt;span id="display_count"&gt;0&lt;/span&gt;</pre>
<p>Remember that the id of text area is &#8220;<span style="color: #000080;">word_coun</span>t&#8221; and &#8220;<span style="color: #000080;">display_count</span>&#8220;.</p>
<p>Now, let look at the jQuery code for displaying word count of text area , note that we are calling the function wordCount() which we&#8217;ve just developed in the plugin of jQuery.</p>
<pre class="prettyprint">$('#word_count').wordCount();</pre>
<p><strong>Note: </strong>display_count  is default id of element which is already defined in the plugin if you want to use the different id of elment then you&#8217;ve to override the value of variable <strong>counterElement</strong> which contains the <span style="color: #000080;">id</span> of element displaying word count.</p>
<pre class="prettyprint">$('#word_count').wordCount({counterElement:"word_counter"});</pre>
<p><a href="http://roshanbh.com.np/codes/jquery-word-count.zip"><strong>DOWNLOAD EXAMPLE CODE </strong></a></p>
<img src="http://roshanbh.com.np/?ak_action=api_record_view&id=299&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://roshanbh.com.np/2008/10/jquery-plugin-word-counter-textarea.html/feed</wfw:commentRss>
		<slash:comments>44</slash:comments>
		</item>
		<item>
		<title>Creating and Parsing JSON data with PHP</title>
		<link>http://roshanbh.com.np/2008/10/creating-parsing-json-data-php.html</link>
		<comments>http://roshanbh.com.np/2008/10/creating-parsing-json-data-php.html#comments</comments>
		<pubDate>Sat, 04 Oct 2008 18:10:51 +0000</pubDate>
		<dc:creator>Roshan</dc:creator>
				<category><![CDATA[how-to]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[web services]]></category>
		<category><![CDATA[json]]></category>

		<guid isPermaLink="false">http://roshanbh.com.np/?p=293</guid>
		<description><![CDATA[Yesterday, I was in a party and a guy came near to me and asked me what is JSON and how can handle it via PHP. Today, I&#8217;m going to tell you something about JSON data and how we can handle them via PHP. Although, JSON stands JavaScript Object Notation, it is used by many [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float:right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F10%2Fcreating-parsing-json-data-php.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F10%2Fcreating-parsing-json-data-php.html&amp;source=roshanbh&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p style="text-align: justify;">Yesterday, I was in a party and a guy came near to me and asked me what is JSON and how can handle it via PHP. Today, I&#8217;m going to tell you something about JSON data and how we can handle them via PHP. Although, JSON stands <strong><a href="http://www.json.org/" target="_blank">JavaScript Object Notation</a></strong>, it is used by many other technologies like PHP and Java for data interchange format over the Internet.</p>
<p><span id="more-293"></span></p>
<h4>What is JSON?</h4>
<p style="text-align: justify;">JSON is ultra-weight data interchange data format used over the internet for transferring the data. While XML is a dominant data interchange format over the internet but JSON is less complex and light-weight data.</p>
<p style="text-align: justify;">Though it was first made to be used with JavaScript for accessing remote data, it is now used by many other languages because JSON data is platform independent data format.</p>
<h4>Data Types and Example of JSON data</h4>
<p>JSON supports various kind of data types which included numbers, strings, booleans as well as array datas and obviously object (collection of key:value pairs, comma-separated and enclosed in curly brackets).</p>
<p>Now, let&#8217;s look at the example of simple format of JSON data for a detail of a employee,</p>
<pre class="prettyprint" style="overflow:auto">{"id":"1","name":"mike","country":"usa","office":["microsoft","oracle"]}</pre>
<h4>Creating and Parsing JSON data format in PHP</h4>
<p>To handle JSON data there is <a href="http://www.php.net/json" target="_blank">JSON extension</a> in PHP which is aviable after PHP 5.2.0. Two funcitons : <a href="http://www.php.net/manual/en/function.json-encode.php">json_encode()</a> and <a href="http://www.php.net/manual/en/function.json-decode.php">json_decode()</a> are very useful converting and parsing JSON data through PHP.</p>
<p>First of all, let&#8217;s look at the PHP code to create the JSON data format of above example using array of PHP.</p>
<pre class="prettyprint" style="overflow:auto">$json_data = array ('id'=&gt;1,'name'=&gt;"mike",'country'=&gt;'usa',"office"=&gt;array("microsoft","oracle"));
echo json_encode($json_data);</pre>
<p>The above code generates the JSON data exactly as above. Now, let&#8217;s decode above JSON data in PHP.</p>
<pre class="prettyprint" style="overflow:auto">$json_string='{"id":1,"name":"mike","country":"usa","office":["microsoft","oracle"]} ';
$obj=json_decode($json_string);</pre>
<p>Now, the $obj variable contains JSON data parsed in PHP object which you can display using code below.</p>
<pre class="prettyprint" style="overflow:auto">echo $obj-&gt;name; //displays mike
echo $obj-&gt;office[0]; //displays microsoft</pre>
<p>As you can guess,$obj-&gt;office is an array and you can loop through it using <a href="http://www.php.net/foreach" target="_blank">foreach</a> loop of PHP,</p>
<pre class="prettyprint" style="overflow:auto">foreach($obj-&gt;office as $val)
    echo $val;</pre>
<img src="http://roshanbh.com.np/?ak_action=api_record_view&id=293&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://roshanbh.com.np/2008/10/creating-parsing-json-data-php.html/feed</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>Getting random number between range of two numbers in JavaScript</title>
		<link>http://roshanbh.com.np/2008/09/get-random-number-range-two-numbers-javascript.html</link>
		<comments>http://roshanbh.com.np/2008/09/get-random-number-range-two-numbers-javascript.html#comments</comments>
		<pubDate>Tue, 30 Sep 2008 10:36:26 +0000</pubDate>
		<dc:creator>Roshan</dc:creator>
				<category><![CDATA[how-to]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[random]]></category>
		<category><![CDATA[random number]]></category>

		<guid isPermaLink="false">http://roshanbh.com.np/?p=291</guid>
		<description><![CDATA[Yesterday, Steve asked me how can we have random number function in JavaScript like rand() function of PHP where the programmer can specify the range of two numbers within which we need the random number. Today, I&#8217;m going to share two functions in JavaScript, In first function , you can specify the number and the [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float:right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F09%2Fget-random-number-range-two-numbers-javascript.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F09%2Fget-random-number-range-two-numbers-javascript.html&amp;source=roshanbh&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p style="text-align: justify;">Yesterday, Steve asked me how can we have random number function in JavaScript like rand() function of PHP where the programmer can specify the range of two numbers within which we need the random number. Today, I&#8217;m going to share two functions in JavaScript, In first function , you can specify the number and the function generate the random number between 1 and N. In another JavaScript function, you can specify range of two numbers between which you&#8217;ve to get a random number. Furthermore, there is optional last parameter in these function for decimal places, if provided, will return the random number with the decimal places specified in the third parameter.<br />
<span id="more-291"></span></p>
<h4>Getting random number in JavaScript</h4>
</p>
<p style="text-align: justify;">Getting random number is very easy you can use JavaScript function random() of Math object to get the random number between 0 and 1. For example, above JavaScript statement returns a random number between 0 and 1.</p>
<pre class="prettyprint">alert(Math.random()); // returns number like 0.3871769046200184</pre>
<h4>JavaScript function to get random number between 1 and N</h4>
<pre class="prettyprint" style="overflow:auto">//function to get random number from 1 to n
function randomToN(maxVal,floatVal)
{
   var randVal = Math.random()*maxVal;
   return typeof floatVal=='undefined'?Math.round(randVal):randVal.toFixed(floatVal);
}</pre>
<p style="text-align: justify;">As, you can see in the above JavaScript function, there are two parameters. One for the maximum value(N) up to which random number have to be generated. The second parameter is optional which specifies number of digits after decimal point.If not provided, this function returns integer.</p>
<h4>JavaScript function to get random number between a range</h4>
<pre class="prettyprint" style="overflow:auto">//function to get random number upto m
function randomXToY(minVal,maxVal,floatVal)
{
  var randVal = minVal+(Math.random()*(maxVal-minVal));
  return typeof floatVal=='undefined'?Math.round(randVal):randVal.toFixed(floatVal);
}</pre>
<p style="text-align: justify;">The above JavaScript funciton accepts three parameters.The first and second parameter is mandatory while the third is optional. The first and second parameter specifies the range between which the random number has to be generated. The thir parameter is optional which specifies number of floating point digits, if not provided, the above JavaScript function returns integer random number.</p>
<img src="http://roshanbh.com.np/?ak_action=api_record_view&id=291&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://roshanbh.com.np/2008/09/get-random-number-range-two-numbers-javascript.html/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Get free ebooks of essential PHP and JavaScript tips , tricks &amp; Hacks</title>
		<link>http://roshanbh.com.np/2008/08/free-ebook-essential-php-javascript-tips-tricks-hacks.html</link>
		<comments>http://roshanbh.com.np/2008/08/free-ebook-essential-php-javascript-tips-tricks-hacks.html#comments</comments>
		<pubDate>Sun, 31 Aug 2008 18:45:24 +0000</pubDate>
		<dc:creator>Roshan</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[ebook]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[free ebook]]></category>

		<guid isPermaLink="false">http://roshanbh.com.np/?p=243</guid>
		<description><![CDATA[As you might know that this blog and tradepub.com are providing free magazines to the reader of this blog. You can check the free magazines and E-book in the free magazines resource of this blog. You can find a collection of great resources of IT knowledge from here. And, today I&#8217;m here to highlight the [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float:right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F08%2Ffree-ebook-essential-php-javascript-tips-tricks-hacks.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F08%2Ffree-ebook-essential-php-javascript-tips-tricks-hacks.html&amp;source=roshanbh&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p style="text-align: justify;">As you might know that this blog and tradepub.com are providing free magazines to the reader of this blog. You can check the free magazines and E-book in the <a href="http://roshanbh.tradepub.com">free magazines</a> resource of this blog. You can find a collection of great resources of IT knowledge from here. And, today I&#8217;m here to highlight the great E-books from sitepoint.com on essential PHP and JavaScript tips , tricks  and other resources.</p>
<p><span id="more-243"></span></p>
<h4>Free E-book on the essential tips, tricks and hacks of JavaScript and PHP</h4>
<p style="text-align: justify;">You can find the great list of resources for the web developer in the list below. You can check them out grab a copy of your E-book right now.</p>
<ul>
<li><strong><a href="http://roshanbh.tradepub.com/free/w_sitb02/" target="_blank">The PHP Anthology: 101 Essential Tips, Tricks &amp; Hacks, 2nd Edition &#8211; Free 207 Page Preview!</a></strong></li>
<li><strong> <a href="http://roshanbh.tradepub.com/free/w_sitb04/" target="_blank">The JavaScript Anthology: 101 Essential Tips, Tricks &amp; Hacks &#8211; Free 158 Page Preview</a></strong></li>
</ul>
<p style="text-align: justify;">Other resources which are be very useful for the web developer. Do check them out and get a copy of yours.</p>
<ul>
<li><strong><a href="http://roshanbh.tradepub.com/free/w_sitb01/" target="_blank">The Principles Of Project Management &#8211; Free 66 Page Preview!</a></strong></li>
<li><strong><a href="http://roshanbh.tradepub.com/free/w_sitb03/" target="_blank">The ASP.NET 2.0 Anthology: 101 Essential Tips, Tricks &amp; Hacks &#8211; Free 156 Page Preview</a></strong></li>
<li><strong><a href="http://roshanbh.tradepub.com/free/w_sitb05/" target="_blank">Run Your Own Web Server Using Linux &amp; Apache &#8211; Free 191 Page Preview</a></strong></li>
<li><strong><a href="http://roshanbh.tradepub.com/free/w_sitb03/" target="_blank">Remote Replication Best Practices for Oracle 10g using XP Continuous Access</a></strong></li>
<li><strong><a href="http://roshanbh.tradepub.com/free/w_hp24" target="_blank">Best Practices for Implementing HP Quality Center Software</a></strong></li>
</ul>
<img src="http://roshanbh.com.np/?ak_action=api_record_view&id=243&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://roshanbh.com.np/2008/08/free-ebook-essential-php-javascript-tips-tricks-hacks.html/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Handling array of HTML Form Elements in JavaScript and PHP</title>
		<link>http://roshanbh.com.np/2008/08/handling-array-html-form-elements-javascript-php.html</link>
		<comments>http://roshanbh.com.np/2008/08/handling-array-html-form-elements-javascript-php.html#comments</comments>
		<pubDate>Wed, 27 Aug 2008 19:46:30 +0000</pubDate>
		<dc:creator>Roshan</dc:creator>
				<category><![CDATA[how-to]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tips and technique]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://roshanbh.com.np/?p=240</guid>
		<description><![CDATA[Today, I would like to share the way of handling array of HTML FORM elements using JavaScript and PHP.Well, it&#8217;s very easy to get the data from the array of HTML form elements in PHP and using them but in JavaScript it&#8217;s a bit tricky to handle the array of HTML form elements. I had [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float:right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F08%2Fhandling-array-html-form-elements-javascript-php.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F08%2Fhandling-array-html-form-elements-javascript-php.html&amp;source=roshanbh&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p style="text-align: justify;">Today, I would like to share the way of handling array of HTML FORM elements using JavaScript and PHP.Well, it&#8217;s very easy to get the data from the array of HTML form elements in PHP and using them but in JavaScript it&#8217;s a bit tricky to handle the array of HTML form elements. I had a hard time to handle them via JavaScript in past thats why I&#8217;m posting it here so that people will not have hard time to cope with array of form elements in JavaScript and PHP.</p>
<p><span id="more-240"></span></p>
<h4>Array of HTML form elements</h4>
<p style="text-align: justify;">You can create the array of Form Elements for grouping the similar kind of object or data. The array of elements are very useful in the context where you don&#8217;t know how many similar kind of data user have to enter. For example, you have a form where user have to enter his education qualification then you might not know how many of the textboxes are required for a person and in such kind situation you can dynamically generate array of the elements in the form for entering such kind of information.</p>
<pre class="prettyprint" style="overflow:auto">&lt;input name="education[]" type="text" size="20" maxlength="40" /&gt;
&lt;input name="education[]" type="text" size="20" maxlength="40" /&gt;
&lt;input name="education[]" type="text" size="20" maxlength="40" /&gt;</pre>
<p>As you can in the above code, there are array element of textbox defined with the name &#8220;education&#8221;.Now, let&#8217;s see how can we handle them via JavaScript and PHP.</p>
<h4>How to handle array of HTML form elements using PHP</h4>
<p style="text-align: justify;">If you submit the the the form with the above the array of elements then you can assess it via array of $_POST['education'] in PHP. You can use foreach() loop to access the value of the value of these form elements via PHP.</p>
<pre class="prettyprint" style="overflow:auto">foreach($_POST['education'] as $key=&gt;$value)
 echo $key.' '.$value;</pre>
<p style="text-align: justify;">Normally, posted variable are contained within the POST array but when you post the array of Form Elements then at that time the values are contained within the array of array i.e within $_POST['education'] in above exmaple.</p>
<h4>How to handle array of Form elements using JavaScript</h4>
<p style="text-align: justify;">Handling the array of Form element part is a bit tricky. Now, let try to access the values of the above elements using JavaScript. First, let&#8217;s store the above object in a JavaScript variable</p>
<pre class="prettyprint" style="overflow:auto">var mutli_education = document.form_name.elements["education[]"];</pre>
<p style="text-align: justify;">After storing the object in the variable, we can access the individual variables in the following way in JavaScript</p>
<pre class="prettyprint">for(i=0;i&lt;mutli_education.length;i++)
{
 alert(mutli_education[i].value);
}</pre>
<p style="text-align: justify;">As you can see, you can get how many elements are there in the array using the <span style="color: #000080;">lengh </span>property and you can use the <span style="color: #000080;">value</span> property to get the value of the indivisual element.</p>
<img src="http://roshanbh.com.np/?ak_action=api_record_view&id=240&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://roshanbh.com.np/2008/08/handling-array-html-form-elements-javascript-php.html/feed</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>Move an object on mouse wheel scroll event using JavaScript</title>
		<link>http://roshanbh.com.np/2008/08/move-object-mouse-wheel-scroll-event-javascript.html</link>
		<comments>http://roshanbh.com.np/2008/08/move-object-mouse-wheel-scroll-event-javascript.html#comments</comments>
		<pubDate>Tue, 19 Aug 2008 08:27:34 +0000</pubDate>
		<dc:creator>Roshan</dc:creator>
				<category><![CDATA[how-to]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[tips and technique]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[mouse]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://roshanbh.com.np/?p=226</guid>
		<description><![CDATA[Today, I&#8217;ve come along with another post where you&#8217;ll see how to move a object within web page when you scroll the mouse wheel using JavaScript.In this example, when you move the mouse wheel the object i.e div moves upwards or downwards depending upon the scrolling direction the mouse wheel. Now, let&#8217;s look at the [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float:right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F08%2Fmove-object-mouse-wheel-scroll-event-javascript.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F08%2Fmove-object-mouse-wheel-scroll-event-javascript.html&amp;source=roshanbh&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p style="text-align: justify;">Today, I&#8217;ve come along with another post where you&#8217;ll see how to move a object within web page when you scroll the mouse wheel using JavaScript.In this example, when you move the mouse wheel the object i.e <strong>div </strong>moves upwards or downwards depending upon the scrolling direction the mouse wheel. Now, let&#8217;s look at the detail of this tutorial in JavaScript.</p>
<p><span id="more-226"></span></p>
<h4><a href="http://roshanbh.com.np/examples/mouse-wheel.html" target="_blank">View Live Demo</a></h4>
<h4>HTML and CSS for object to be scrolled on mouse wheel movement</h4>
<pre class="prettyprint" style="overflow:auto ">&lt;div id="object"&gt;This block moves as you move mouse wheel.&lt;/div&gt;</pre>
<p style="text-align: justify;">As you can see above code, the object which is going to be moved is placed in the division with id <strong>object</strong>. For the above division, I&#8217;ve defined style and you can see the CSS code below. Remember that ,you can change the below CSS code according to your need but remember that the position should be <strong>absolute</strong>.</p>
<pre style="border: 1px solid #888888; padding: 2px"><span style="color: #ff00ff;">#object {</span>
<span style="color: #333399;">font-weight:bold;
background:yellow;
padding:5px;
width:300px;
position:absolute;
left:500px;
top:200px;</span>
<span style="color: #ff00ff;">}</span></pre>
<h4>JavaScript code for handling mouse scroll event.</h4>
<pre class="prettyprint" style="overflow:auto ">window.onload = function()
{
  //adding the event listerner for Mozilla
  if(window.addEventListener) document.addEventListener('DOMMouseScroll', moveObject, false);
  //for IE/OPERA etc
  document.onmousewheel = moveObject;
}</pre>
<p>First of all, we need to attach the mouse wheen scroll event to the document.As you can see in the first line of above function,  event listner &#8220;moveObject&#8221; is added to the mouse scroll event in the document for Mozilla browsers and in the second line event handler &#8220;moveObject&#8221; is called for <strong>document.onmousewheel</strong> event for browsers like IE and Opera etc.</p>
<p>Now look at the mouse wheel scroll event handler function &#8220;moveObject&#8221;</p>
<pre class="prettyprint" style="overflow:auto ">function moveObject(event)
{
  var delta = 0;
  if (!event) event = window.event;
  // normalize the delta
  if (event.wheelDelta)
  {
    // IE &amp; Opera
   delta = event.wheelDelta / 120;
  }
  else if (event.detail) // W3C
  {
    delta = -event.detail / 3;
  }
  var currPos=document.getElementById('object').offsetTop;
  //calculating the next position of the object
  currPos=parseInt(currPos)+(delta*10);
  //moving the position of the object
  document.getElementById('object').style.top=currPos+"px";
}</pre>
<p style="text-align: justify;">As you can see in the above function first the scrolling <strong>delta</strong> value is calculated. The delta variable holds the value  -1 or 1 depending upon the movement of the wheel.</p>
<p style="text-align: justify;">After calculating the detail value, the top offset of the object is taken using <strong>offsetTop</strong> property using JavaScript. After that, the next position of the object is calculated, which is 10 pixel up or down from the current position of the object.</p>
<p style="text-align: justify;">Finally, style.top property is used to set the current position of the object using JavaScript.</p>
<h4><a href="http://roshanbh.com.np/codes/mouse-wheel.zip" target="_blank">Download Full Source Code </a></h4>
<img src="http://roshanbh.com.np/?ak_action=api_record_view&id=226&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://roshanbh.com.np/2008/08/move-object-mouse-wheel-scroll-event-javascript.html/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>How to hide actual URL in the status bar of all browsers?</title>
		<link>http://roshanbh.com.np/2008/08/different-status-bar-text-hyperlink-mouseover.html</link>
		<comments>http://roshanbh.com.np/2008/08/different-status-bar-text-hyperlink-mouseover.html#comments</comments>
		<pubDate>Sat, 09 Aug 2008 17:50:46 +0000</pubDate>
		<dc:creator>Roshan</dc:creator>
				<category><![CDATA[how-to]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[tips and technique]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[status-bar]]></category>
		<category><![CDATA[url]]></category>

		<guid isPermaLink="false">http://roshanbh.com.np/?p=210</guid>
		<description><![CDATA[Yesterday, Jacob mailed me and asked me how can I show different text or link in the status bar of browsers like Firefox or safari when mouse is over the link.He found the technique which only worked for IE but not for other browser but I&#8217;ve come up with a technique which works for all [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float:right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F08%2Fdifferent-status-bar-text-hyperlink-mouseover.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F08%2Fdifferent-status-bar-text-hyperlink-mouseover.html&amp;source=roshanbh&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p style="text-align: justify;">Yesterday, Jacob mailed me and asked me how can I show different text or link in the status bar of browsers like Firefox or safari when mouse is over the link.He found the technique which only worked for IE but not for other browser but I&#8217;ve come up with a technique which works for all browser. This kind of technique is quite useful if you want to hide the actual link in status bar of browsers and show the different URL instead of actual one.</p>
<p><span id="more-210"></span></p>
<h4>Old technique to display hide actual URL  in the status bar</h4>
<p style="text-align: justify;">If you search in google with the keyword <a href="http://www.google.com/search?q=change+status+bar+text&amp;ie=utf-8&amp;oe=utf-8&amp;aq=t&amp;rls=org.mozilla:en-US:official&amp;client=firefox-a" target="_blank">change status bar text </a>, you&#8217;ll find that many codes in different websites which are using <strong>window.status</strong> to change the text of the status bar while mouse is over the link. For example,</p>
<pre class="prettyprint" style="overflow:auto">&lt;a href="http://www.sell.com/?referrer=225" onMouseOver="window.status='http://www.sell.com';
return true" onMouseOut="window.status=''"&gt;Click here &lt;/a&gt;</pre>
<p style="text-align: justify;">The above link displays &#8220;http://www.sell.com&#8221; instead of &#8220;http://www.sell.com/?referrer=225&#8243; in the status bar when mouse is mover the hyperlink. But, the main drawback of above code is that it only works in Internet Explorer(IE) . It doesn&#8217;t change the status bar text of the link in any other browsers like &#8220;Firefox&#8221;, &#8220;Safari&#8221; etc.</p>
<h4>How to display diferent URL of links in status bar of Firefox , Safari etc ?</h4>
<p style="text-align: justify;">To change the satus bar text of the the link in firefox and safari you&#8217;ve to just use a small technique with the help of &#8220;<strong>href</strong>&#8221; and &#8220;<strong>Onclick</strong>&#8221; attribute of the hyperlink. Let&#8217;s look at the this technique step by step,</p>
<ol>
<li>First, make a javaScript function and define it exactly as below,
<pre class="prettyprint" style="overflow:auto">    &lt;script language="javascript" type="text/javascript"&gt;
     function redirect(URL)
     {
       document.location=URL;
       return false;
     }
    &lt;/script&gt;</pre>
</li>
<li>Now, define the hyperlink with the status bar text in <strong>href</strong> attribute and call the above function from <strong>onClick</strong> attribute of the link like below,
<pre class="prettyprint" style="overflow:auto">&lt;a href="http://www.sell.com" onclick="return
redirect('http://www.sell.com/?referrer=225');"&gt;Click here&lt;/a&gt;</pre>
</li>
</ol>
<p style="text-align: justify;">As we know the we see the text in status bar which is defined in the href attribute of the hyperlink. And when you click the link, code within <strong>onclick</strong> event of element is called. We&#8217;ve taken the benefit of this phenomenon to show the different text .</p>
<p style="text-align: justify;">But remember, this technique also have a drawback as it doesn&#8217;t work if JavaScript is diabled in the web browsers. In that case, the browers will be redirecteed to URL in the <strong>href</strong> attribute. If you worried about disabled JavaScript then you can check this post to knnow how to <a href="http://roshanbh.com.np/2008/04/how-to-know-handle-disabled-javascript.html">handle disabled JavaScript in browser</a>.</p>
<img src="http://roshanbh.com.np/?ak_action=api_record_view&id=210&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://roshanbh.com.np/2008/08/different-status-bar-text-hyperlink-mouseover.html/feed</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>How to display pop-up message on mouse clicked position using jQuery</title>
		<link>http://roshanbh.com.np/2008/08/pop-up-message-mouse-clicked-position-jquery.html</link>
		<comments>http://roshanbh.com.np/2008/08/pop-up-message-mouse-clicked-position-jquery.html#comments</comments>
		<pubDate>Mon, 04 Aug 2008 16:39:20 +0000</pubDate>
		<dc:creator>Roshan</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[message box]]></category>

		<guid isPermaLink="false">http://roshanbh.com.np/?p=203</guid>
		<description><![CDATA[Yesterday, my friend Sujit asked me how can we get the mouse clicked position and display the pop-up message in that mouse clicked position using jQuery.Today, I&#8217;ve come up with the tutorial for the solution of this problem. In this tutorial, you&#8217;ll see how to display the pop-up message in mouse clicked position using jQuery. [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float:right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F08%2Fpop-up-message-mouse-clicked-position-jquery.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F08%2Fpop-up-message-mouse-clicked-position-jquery.html&amp;source=roshanbh&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p style="text-align: justify;">Yesterday, my friend <a href="http://sks.com.np" target="_blank">Sujit</a> asked me how can we get the mouse clicked position and display the pop-up message in that mouse clicked position using jQuery.Today, I&#8217;ve come up with the tutorial for the solution of this problem. In this tutorial, you&#8217;ll see how to display the pop-up message in mouse clicked position using jQuery. When you click the mouse in any position of document, the pop-up message gets displayed with the mouse position around the middle part of the pop-up message.</p>
<p><span id="more-203"></span></p>
<p style="text-align: justify;"><a href="http://roshanbh.com.np/examples/popup-message/" target="_blank"><strong>Live Demo</strong></a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://roshanbh.com.np/codes/popup-message.zip"><strong>Download Full Source Code</strong></a></p>
<h4>HTML code to display pop-up message on mouse clicked position</h4>
<pre class="prettyprint" style="overflow:auto ">&lt;div id="popuup_div" class="popup_msg"&gt;
   ....you can write the mssage here...
&lt;/div&gt;</pre>
<p style="text-align: justify;">As you can above, the element displaying pop-up message is defined with the id &#8220;<span style="color: #000080;">popup_div</span>&#8221; and class of this element is &#8220;<span style="color: #000080;">popup_msg</span>&#8220;. You can write your custom message inside that div.</p>
<h4>CSS code to display pop-up message on mouse clicked position</h4>
<pre style="border: 1px solid #888888; padding: 2px"><span style="color: #ff00ff;">.popup_msg{</span>
<span style="color: #333399;">position:absolute;
z-index:10;
width:172px;
height:102px;
text-align:center;
color:#FF0000;
font: 14px Verdana, Arial, Helvetica, sans-serif;
background:url(bg_image.gif) bottom right no-repeat;
display:none;</span>
<span style="color: #ff00ff;">}</span></pre>
<p style="text-align: justify;">The above CSS attribute is straightforward and you can change the attribute according to your requirement. But remember that, the <span style="color: #000080;">position</span> attribute should be set to <span style="color: #000080;">absolute</span> value and <span style="color: #000080;">z-index</span> should be greater than the other element&#8217;s z-index. Furthermore, the width and height attribute must be set according to the background image of pop-up message.</p>
<h4>JavaScript ( jQuery ) code for displaying pop-up message</h4>
<pre class="prettyprint" style="overflow:auto ">$(document).click(function(e)
{
  //getting height and width of the message box
  var height = $('#popuup_div').height();
  var width = $('#popuup_div').width();
  //calculating offset for displaying popup message
  leftVal=e.pageX-(width/2)+"px";
  topVal=e.pageY-(height/2)+"px";
  //show the popup message and hide with fading effect
  $('#popuup_div').css({left:leftVal,top:topVal}).show().fadeOut(1500);
});</pre>
<p style="text-align: justify;">As the above code is well document. I&#8217;m just going to give you the brief description. First of all, we took the height and width of the pop-up element. After that, we&#8217;ve calculated the <span style="color: #000080;">left</span> and <span style="color: #000080;">top</span> offset of element so that it gets displayed with the mouse position is around in it&#8217;s middle part. of the element With the last  line of jQuery code, pop-up message&#8217;s left and top position is set and displayed. This pop-up message gets hidden with fading effect with the <span style="color: #000080;">fadeOut()</span> function of jQuery.</p>
<p style="text-align: justify;"><a href="http://roshanbh.com.np/examples/popup-message/" target="_blank"><strong>Live Demo</strong></a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://roshanbh.com.np/codes/popup-message.zip"><strong>Download Full Source Code</strong></a></p>
<img src="http://roshanbh.com.np/?ak_action=api_record_view&id=203&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://roshanbh.com.np/2008/08/pop-up-message-mouse-clicked-position-jquery.html/feed</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>jQuery is the most popular JavaScript and Ajax Framework</title>
		<link>http://roshanbh.com.np/2008/07/jquery-most-popular-javascript-ajax-framework.html</link>
		<comments>http://roshanbh.com.np/2008/07/jquery-most-popular-javascript-ajax-framework.html#comments</comments>
		<pubDate>Tue, 29 Jul 2008 17:54:59 +0000</pubDate>
		<dc:creator>Roshan</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Poll & Competetion]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://roshanbh.com.np/?p=187</guid>
		<description><![CDATA[In last poll, Many people supported Zend Framework as the first choice for the PHP developments. And, today I would like to announce the result of the poll &#8220;which is the best JavaScript and Ajax framework ?&#8221; I would like to thanks all of you 690 voters who has participated in this poll. Today, I&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float:right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F07%2Fjquery-most-popular-javascript-ajax-framework.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F07%2Fjquery-most-popular-javascript-ajax-framework.html&amp;source=roshanbh&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p style="text-align: justify;">In last poll, Many people supported <a href="http://http://roshanbh.com.np/2008/06/zend-framework-most-popular-php-framework.html">Zend Framework as the first choice for the PHP developments</a>. And, today I would like to announce the result of the poll &#8220;which is the <a href="http://roshanbh.com.np/2008/06/which-is-the-best-javascript-ajax-framework.html">best JavaScript and Ajax framework</a> ?&#8221; I would like to thanks all of you 690 voters who has participated in this poll. Today, I&#8217;ve no hesitation on saying that jQuery is the most popular and leading choice of web developer as a JavaScript and Ajax framework.</p>
<p><span id="more-187"></span></p>
<p style="text-align: justify;">You can look at the poll result below. There is no dispute that  <a href="http://ejohn.org/" target="_blank">John Resig&#8217;s</a> JavaScript library (jQuery) is their first choice as 52% web developers have voted for this library. In this blog, I&#8217;ve also posted many jQuery tutorials, <a href="http://roshanbh.com.np/category/jquery">Check them out</a> .</p>
<p>[poll id="2"]</p>
<img src="http://roshanbh.com.np/?ak_action=api_record_view&id=187&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://roshanbh.com.np/2008/07/jquery-most-popular-javascript-ajax-framework.html/feed</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>How to disable context menu in browsers ?</title>
		<link>http://roshanbh.com.np/2008/06/disable-right-click-context-menu.html</link>
		<comments>http://roshanbh.com.np/2008/06/disable-right-click-context-menu.html#comments</comments>
		<pubDate>Mon, 30 Jun 2008 17:51:03 +0000</pubDate>
		<dc:creator>Roshan</dc:creator>
				<category><![CDATA[how-to]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[tips and technique]]></category>
		<category><![CDATA[technique]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://roshanbh.com.np/?p=141</guid>
		<description><![CDATA[Today, I would like to share a fairly simple technique to disable right click menu of the website. I was using around 10-15 lines of JavaScript code to disable the menu that appears on the right click on the browser. &#160; &#160; Here the code which you can use in the body tag of the [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float:right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F06%2Fdisable-right-click-context-menu.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F06%2Fdisable-right-click-context-menu.html&amp;source=roshanbh&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Today, I would like to share a fairly simple technique to disable right click menu of the website. I was using around 10-15 lines of JavaScript code to disable the menu that appears on the right click on the browser.</p>
<p><span id="more-141"></span></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p style="text-align: justify;">Here the code which you can use in the body tag of the document.</p>
<pre class="prettyprint">&lt;body oncontextmenu="return false;"&gt;</pre>
<p style="text-align: justify;">As you can see, this code blocks the context menu i.e the menu which appears on the right click on the browsers. I&#8217;ve tested this code with major four browsers IE. Firefox, Opera and Safari. It worked well in all three browsers except Opera.</p>
<img src="http://roshanbh.com.np/?ak_action=api_record_view&id=141&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://roshanbh.com.np/2008/06/disable-right-click-context-menu.html/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Which is the best JavaScript and Ajax Framework ?</title>
		<link>http://roshanbh.com.np/2008/06/which-is-the-best-javascript-ajax-framework.html</link>
		<comments>http://roshanbh.com.np/2008/06/which-is-the-best-javascript-ajax-framework.html#comments</comments>
		<pubDate>Thu, 26 Jun 2008 09:05:26 +0000</pubDate>
		<dc:creator>Roshan</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Poll & Competetion]]></category>
		<category><![CDATA[ajax framework]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://roshanbh.com.np/?p=137</guid>
		<description><![CDATA[Last time, I had published a poll asking which is the best PHP framework and in that poll Zend Framework stand out itself to be the most popular PHP framework among the PHP developers. This time ,I&#8217;ve come up with another Poll and I would you to participate in this POLL &#8220;Which is the best [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float:right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F06%2Fwhich-is-the-best-javascript-ajax-framework.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F06%2Fwhich-is-the-best-javascript-ajax-framework.html&amp;source=roshanbh&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p style="text-align: justify;">Last time, I had published a poll asking which is the <a title="Best PHP Framework" href="http://roshanbh.com.np/2008/06/which-is-the-best-php-framework.html">best PHP framework</a> and in that poll Zend Framework stand out itself to be the most <a href="http://roshanbh.com.np/2008/06/zend-framework-most-popular-php-framework.html">popular PHP framework</a> among the PHP developers. This time ,I&#8217;ve come up with another Poll and I would you to participate in this POLL &#8220;Which is the best JavaScript and Ajax Framework?&#8221;.</p>
<p><span id="more-137"></span></p>
<p style="text-align: justify;">There are many JavaScript and Ajax framework available in the web and I think a lot of Web developers are confused which one to begin with. Today, I would like to hear from you which is the best JavaScript Framework among the popular JavaScript framework <a href="http://jquery.com" target="_blank">jquery</a>, <a href="http://prototypejs.org/" target="_blank">prototype.js</a>, <a href="http://mootools.net/" target="_blank">mootools</a>, <a href="http://dojotoolkit.org/" target="_blank">Dojo</a> and <a href="http://developer.yahoo.com/yui/" target="_blank">YUI</a>.</p>
<p style="text-align: justify;">First let&#8217;s see some facts about these framework.If you look at the <a href="http://www.google.com/trends?q=prototype+%2C+jquery%2C+YUI%2C+dojo%2C+mootools&amp;ctab=0&amp;geo=all&amp;date=all&amp;sort=0" target="_blank">google trend</a> of these JavaScript and Ajax framework Dojo seems to be dominant in the year 2007 but jQuery seems to be popular these days.</p>
<p style="text-align: justify;">And if you look at this <a href="http://mootools.net/slickspeed/" target="_blank">Slick speed selecter test</a> , it seems that Mootools is providing better performance than the other JavaScript frameworks. Prototype.js is one of the oldest JavaScript and Ajax framework which is widely used in many high profile websites over the Internet. Furthermore, YUI which is supported by yahoo and is another strong framework in the list.</p>
<p style="text-align: justify;">If you ask me which one is best JavaScript framework?, My personal favorite is jQuery as you can  see lots of examples in this blog with jQuery. One plus point of jQuery is that it is supported by large community and have a very good <a href="http://docs.jquery.com/Main_Page" target="_blank">documentaion with example in jquery.com</a>.</p>
<p style="text-align: justify;">But I would like to hear from you which JavaScript and Ajax Framework you recommend for other to  use in their project.</p>
<p>[poll id="2"]</p>
<img src="http://roshanbh.com.np/?ak_action=api_record_view&id=137&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://roshanbh.com.np/2008/06/which-is-the-best-javascript-ajax-framework.html/feed</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Prevent your website being displayed inside IFRAME</title>
		<link>http://roshanbh.com.np/2008/06/prevent-website-displayed-inside-iframe.html</link>
		<comments>http://roshanbh.com.np/2008/06/prevent-website-displayed-inside-iframe.html#comments</comments>
		<pubDate>Mon, 23 Jun 2008 11:07:41 +0000</pubDate>
		<dc:creator>Roshan</dc:creator>
				<category><![CDATA[how-to]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[tips and technique]]></category>
		<category><![CDATA[iframe]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://roshanbh.com.np/?p=135</guid>
		<description><![CDATA[Sites like Google Image search and goodphptutorials.com displays the website under the IFRAME and I don&#8217;t think you guyz want your site to be displayed it under the IFRAME. If you want to protect your site to be displayed under the IFRAME then here is the tips for you. &#160; JavaScript Code Prevent web page [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float:right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F06%2Fprevent-website-displayed-inside-iframe.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F06%2Fprevent-website-displayed-inside-iframe.html&amp;source=roshanbh&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p align="justify">Sites like Google Image search and goodphptutorials.com displays the website under the IFRAME and I don&#8217;t think you guyz want your site to be displayed it under the IFRAME.  If you want to protect your site to be displayed under the IFRAME then here is the tips for you.</p>
<p><span id="more-135"></span></p>
<p>&nbsp;</p>
<h4>JavaScript Code Prevent web page being displayed inside iframe</h4>
<p style="text-align: justify;">Place the following piece of code in JavaScript to those pages which you want to prevent being displayed inside the IFRAME.</p>
<pre class="prettyprint" style="overflow:auto">&lt;script type="text/javascript"&gt;
&lt;!--
if (top.location.href != self.location.href)
  top.location.href = self.location.href;
//--&gt;
&lt;/script&gt;</pre>
<p align="justify">The above code is simple and straightforward. First of all, it is checked that if url of the top frame is different to the URL containing the JavaScript code, if they are different then the website comes out of the IFRAME and gets displayed in the browser. This is how we can prevent your web page being displayed inside IFRAME but note that javascript must be enabled otherwise the code won&#8217;t take any action.</p>
<img src="http://roshanbh.com.np/?ak_action=api_record_view&id=135&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://roshanbh.com.np/2008/06/prevent-website-displayed-inside-iframe.html/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Animated content navigation effect using jquery</title>
		<link>http://roshanbh.com.np/2008/05/animated-content-navigation-jquery.html</link>
		<comments>http://roshanbh.com.np/2008/05/animated-content-navigation-jquery.html#comments</comments>
		<pubDate>Thu, 08 May 2008 06:58:20 +0000</pubDate>
		<dc:creator>Roshan</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://roshanbh.com.np/?p=104</guid>
		<description><![CDATA[I always get bored with the same stuffs. And, I see same kind of content navigation to the different websites. Click a link, let&#8217;s the whole web page gets loaded and new page gets displayed. It would be better to show another content in the same page with few animation without loading the whole page. [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float:right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F05%2Fanimated-content-navigation-jquery.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F05%2Fanimated-content-navigation-jquery.html&amp;source=roshanbh&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p align="justify">I always get bored with the same stuffs. And, I see same kind of content navigation to the different websites. Click a link, let&#8217;s the whole web page gets loaded and new page gets displayed. It would be better to show another content in the same page with few animation without loading the whole page.</p>
<p><span id="more-104"></span></p>
<p align="justify">In this post, I&#8217;ll show you how to make various animation to the content using jQuery. First of let&#8217;s start looking at the HTML and CSS code,</p>
<p align="justify"><strong>HTML Code for animated content navigation </strong></p>
<pre class="prettyprint" style="overflow:auto ">&lt;a href="#home" class="linkclass" &gt;Home&lt;/a&gt;
&lt;a href="#about_us" class="linkclass" &gt;About Us&lt;/a&gt;
&lt;a href="#service" class="linkclass" &gt;Services&lt;/a&gt;
&lt;a href="#contact_us" class="linkclass" &gt;Contact Us&lt;/a&gt;

&lt;div class="container"&gt;
    &lt;div id="home" class="msg_body"&gt; content goes here &lt;/div&gt;
    &lt;div id="about_us" class="msg_body"&gt; content goes here &lt;/div&gt;
    &lt;div id="service" class="msg_body"&gt; content goes here &lt;/div&gt;
    &lt;div id="contact_us" class="msg_body"&gt;  content goes here &lt;/div&gt;
&lt;/div&gt;</pre>
<p align="justify">As you can see above, the &#8220;href&#8221; attribute of the anchor tag is pointing to the id of the &#8220;div&#8221;. &#8220;Home&#8221; anchor tag is pointing to &#8220;#home&#8221;. In jquery, id of a element is represented by adding &#8220;#&#8221; prefix to the id of that element.</p>
<p align="justify"><strong>CSS code for animated content navigation</strong></p>
<pre style="border: 1px solid #888888; padding: 2px"><span style="color: #ff00ff;">.container
{</span>
  <span style="color: #333399;"> width:312px;
   margin-top:20px;</span>
<span style="color: #ff00ff;">}
.msg_body
{</span>
 <span style="color: #333399;"> border:1px solid #CCCCCC;
  padding: 5px;
  width: 300px;
  background-color:#F4F4F8;
  text-align:justify;
  position:absolute;</span>
<span style="color: #ff00ff;">}
.linkclass
{</span>
<span style="color: #333399;">  font-weight:bold;
  color:#006699;</span>
<span style="color: #ff00ff;">}</span></pre>
<p align="justify">Above CSS code is pretty straight forward and you can change it according to your need. Note that, there is position attribute to &#8220;absolute&#8221; in the &#8220;msg_body&#8221; class. Now let&#8217;s look at various the javaScript code in jQuery to make the various animated content navigation</p>
<p align="justify"><strong>Faded content navigation</strong></p>
<p align="justify"><strong><a href="http://roshanbh.com.np/examples/content-move/index.html" target="_blank">View Live Demo </a></strong></p>
<pre class="prettyprint" style="overflow:auto"> //hide the all div except first one
$('.msg_body:not(:first)').hide();
//when the anchor is clicked content gets faded
$("a.linkclass").click(function()
{
  $('.msg_body').fadeOut("slow");
  $($(this).attr("href")).fadeIn("slow");
});</pre>
<p align="justify">In the first line of javaScript code, all the element with class &#8220;msg_body&#8221; is made hidden except the first element with same class. And when the anchor with class &#8220;linkclass&#8221; is clicked, the element with class &#8220;msg_body&#8221; gets faded out which is being displayed in browser. And, the element with the id value in the &#8220;href&#8221; attribute of the clicked anchor tag, get displayed in browser with fading effect.</p>
<p align="justify"><strong>Shutter like content navigation effect<br />
</strong></p>
<p align="justify"><strong><a href="http://roshanbh.com.np/examples/content-move/index1.html" target="_blank">View Live Demo </a></strong></p>
<pre class="prettyprint" style="overflow:auto">//hide the all div except first one
$('.msg_body:not(:first)').hide();
//when the anchor is clicked content gets faded
$("a.linkclass").click(function()
{
   $('.msg_body').hide("fast");
   $($(this).attr("href")).show("slow");
});</pre>
<p align="justify">The code is same as the above code but here &#8220;hide()&#8221; and &#8220;show()&#8221; function of jQuery is used to hide and display the content in different manner.</p>
<p align="justify"><strong>Sliding Content Navigation Effect </strong></p>
<p align="justify"><strong><a href="http://roshanbh.com.np/examples/content-move/index3.html" target="_blank">View Live Demo </a></strong></p>
<pre class="prettyprint" style="overflow:auto"> //hide the all div except first one
 $('.msg_body:not(:first)').hide();
//when the anchor is clicked content gets faded
$("a.linkclass").click(function()
{
   $('.msg_body').slideUp("slow");
   $($(this).attr("href")).slideDown("slow"););
});</pre>
<p align="justify">This is another content navigation effect with sliding manner. &#8220;slideUp()&#8221; and &#8220;slideDown()&#8221; functions of jQuery is used to display this kind of effect.</p>
<p align="justify"><strong><a href="http://roshanbh.com.np/codes/content-move.zip">Download full source code</a></strong></p>
<img src="http://roshanbh.com.np/?ak_action=api_record_view&id=104&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://roshanbh.com.np/2008/05/animated-content-navigation-jquery.html/feed</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>How to know and handle disabled javascript in browser</title>
		<link>http://roshanbh.com.np/2008/04/how-to-know-handle-disabled-javascript.html</link>
		<comments>http://roshanbh.com.np/2008/04/how-to-know-handle-disabled-javascript.html#comments</comments>
		<pubDate>Sun, 27 Apr 2008 11:22:31 +0000</pubDate>
		<dc:creator>Roshan</dc:creator>
				<category><![CDATA[how-to]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[tips and technique]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://roshanbh.com.np/2008/04/how-to-know-handle-disabled-javascript.html</guid>
		<description><![CDATA[In this blog, I&#8217;ve been writing a lot of tips and tutorials using JavaScript. I really love JavaScript and hope that you guyz also like it. But what to do when JavaScript is disabled in the client&#8217;s browser?. I would like to redirect the visitor to a warning page where he&#8217;ll be suggested to enable [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float:right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F04%2Fhow-to-know-handle-disabled-javascript.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F04%2Fhow-to-know-handle-disabled-javascript.html&amp;source=roshanbh&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p align="justify">In this blog, I&#8217;ve been writing a lot of tips and tutorials using JavaScript. I really love JavaScript and hope that you guyz also like it. But what to do when JavaScript is disabled in the client&#8217;s browser?. I would like to redirect the visitor to a warning page where he&#8217;ll be suggested to enable the JavaScript.<br />
<span id="more-99"></span><br />
In many scenario, we must need JavaScript in some pages and we never want to process that page.In this post, I&#8217;ll show you how to know and handle the disabled JavaScript in browser.
</p>
<p align="justify">First click on the below link to see a JavaScript enabled page.<strong> Now, disable the javaScript in browser and click the below link.</strong></p>
<p align="justify"><strong><a href="http://roshanbh.com.np/examples/handle-javascript/" target="_blank">View the Demo  </a></strong></p>
<p align="justify"><strong>How to know JavaScript is disabled in browser?</strong></p>
<p align="justify">As you guyz know, <strong>&lt;script&gt;&lt;/script&gt;</strong> tag is used for javaScript. Same way there is <strong>&lt;noscript&gt;&lt;/noscript&gt;</strong> tag which gets in action when the Javascript is diabled in browser.</p>
<pre class="prettyprint" style="overflow: auto">&lt;script&gt;code here gets executed when javascript is enabled&lt;/script&gt;
&lt;noscript&gt;code here gets executed when javascript is diabled&lt;/noscript&gt;</pre>
<p align="justify"><strong>How to handle diabled javascript in browser? </strong></p>
<p align="justify">When javascript is diabled I always want user to be redirected to a page to show warning to enabled javascript.But, JavaScript is diabled how to do this ? well there is meta tag in HTML named &#8220;meta refresh&#8221; which will redirect you to another page in the interval specified in that header</p>
<pre class="prettyprint" style="overflow: auto">&lt;noscript&gt;
  &lt;META HTTP-EQUIV="Refresh" CONTENT="0;URL=disabled.html"&gt;
&lt;/noscript&gt;</pre>
<p align="justify">As, you can see above code inside <strong>noscript</strong>, there is &#8220;meta refresh&#8221; tag with intevel of &#8220;0&#8243; second. As, the javascipt is disabled in that page, the browser gets redirected to &#8220;disabled.html&#8221; to show some warning message</p>
<p align="justify"><strong><a href="http://roshanbh.com.np/codes/handle-disabled-javascript.zip" target="_blank">Download Example Files </a>  </strong></p>
<img src="http://roshanbh.com.np/?ak_action=api_record_view&id=99&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://roshanbh.com.np/2008/04/how-to-know-handle-disabled-javascript.html/feed</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Textbox to accept only numbers (digits) using jquery</title>
		<link>http://roshanbh.com.np/2008/04/textbox-accept-only-numbers-digits.html</link>
		<comments>http://roshanbh.com.np/2008/04/textbox-accept-only-numbers-digits.html#comments</comments>
		<pubDate>Wed, 16 Apr 2008 17:33:41 +0000</pubDate>
		<dc:creator>Roshan</dc:creator>
				<category><![CDATA[how-to]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[textbox]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://roshanbh.com.np/2008/04/textbox-accept-only-numbers-digits.html</guid>
		<description><![CDATA[Few days back, my friend Parleen asked me how can we make a textbox which just accepts only numbers specially digits only. And, for his I come up with this solution of textbox which only accepts digits, and if you try to enter any alpha bates in it then it displays the error message with [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float:right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F04%2Ftextbox-accept-only-numbers-digits.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F04%2Ftextbox-accept-only-numbers-digits.html&amp;source=roshanbh&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p align="justify">Few days back, my friend Parleen asked me how can we make a textbox which just accepts only numbers specially digits only. And, for his I come up with this solution of textbox which only accepts digits, and if you try to enter any alpha bates in it then it displays the error message with animation.</p>
<p><span id="more-88"></span></p>
<p align="justify"><strong><a href="http://roshanbh.com.np/examples/accept-only-digit/" target="_blank">View Demo </a></strong></p>
<p align="justify"><strong>HTML Code </strong></p>
<pre class="prettyprint" style="overflow: auto">&lt;input type="text" name="quantity" id="quantity" /&gt; &lt;span id="errmsg"&gt;&lt;/span&gt;</pre>
<p align="justify">As you can see above, I&#8217;ve given the name and id of textbox to &#8220;quantity&#8221; in this example.This is the textbox which only accepts numbers (digits only). You can see &#8220;span&#8221; after textbox which is used to display the error message with fading effect using jQuery.</p>
<p align="justify"><strong>Javascript Code </strong></p>
<p align="justify">First of all, we need to use jQuery library as we&#8217;re using the jquery&#8217;s function to accept only digits.</p>
<pre class="prettyprint" style="overflow: auto">&lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt;</pre>
<p align="justify">Now le&#8217;ts write the code in JavaScript using jQuery to accept only digits in textbox and displaying error with animation.</p>
<pre class="prettyprint" style="overflow: auto">//when key is pressed in the textbox$("#quantity").keypress(function (e)
{
  //if the letter is not digit then display error and don't type anything
  if( e.which!=8 &amp;&amp; e.which!=0 &amp;&amp; (e.which&lt;48 || e.which&gt;57))
  {
    //display error message
    $("#errmsg").html("Digits Only").show().fadeOut("slow");
    return false;
  }
});</pre>
<p align="justify">When the key is pressed, we&#8217;re using the key&#8217;s ASCII value to check which button is pressed. In first expression, delete, tab or backspace button is is checked and &#8220;8&#8243; is the ASCII values of the Back-space. Digits are checked in the second expression. &#8220;48&#8243; is the ASCII values of &#8220;0&#8243; and &#8220;57&#8243; is the ASCII values of  &#8220;9&#8243;. The the ASCII values of the other digits lies between &#8220;48&#8243; to &#8220;57&#8243;. And, if the key pressed values doesn&#8217;t lies withing these range, then we are displaying the error message with jQuery&#8217;s fading effect.</p>
<p align="justify">And, the &#8220;return false&#8221; statement means that this functions returns false values which means not to type anything on the text box.</p>
<p align="justify"><strong><a href="http://roshanbh.com.np/codes/accept-only-digit.zip" target="_blank">Download Full Source Code</a> </strong></p>
<img src="http://roshanbh.com.np/?ak_action=api_record_view&id=88&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://roshanbh.com.np/2008/04/textbox-accept-only-numbers-digits.html/feed</wfw:commentRss>
		<slash:comments>39</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 2/64 queries in 0.447 seconds using disk: basic
Object Caching 2206/2357 objects using disk: basic

Served from: roshanbh.com.np @ 2012-02-08 20:58:45 -->
