<?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>Php Development &#187; javascript</title>
	<atom:link href="http://www.maheshchari.com/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.maheshchari.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Tue, 17 Jan 2012 02:42:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>draw eclipse using javascript</title>
		<link>http://www.maheshchari.com/draw-eclipse-using-javascript/</link>
		<comments>http://www.maheshchari.com/draw-eclipse-using-javascript/#comments</comments>
		<pubDate>Thu, 06 Jan 2011 21:42:13 +0000</pubDate>
		<dc:creator>mahesh chari</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.maheshchari.com/?p=592</guid>
		<description><![CDATA[How to draw eclipse using HTML4,CSS2,jQuery Please refer my previous post draw circle ,to get basic idea. Circle is instance of an Eclipse where both xradius and yradius are equal. See the quick demo how it works and looks here. Here is the idea how we get the points on Eclipse using trigonametry. You can [...]]]></description>
			<content:encoded><![CDATA[<h1>How to draw eclipse using HTML4,CSS2,jQuery</h1>
<p>Please refer my <a href="http://www.maheshchari.com/draw-circle-with-javascript/" target="_blank">previous post</a> draw circle ,to get basic idea. <strong>Circle</strong> is instance of an <strong>Eclipse</strong> where both <strong>xradius</strong> and <strong>yradius</strong> are equal. </p>
<p>See the quick <a href="http://demo.maheshchari.com/draweclipse/example3.html" target="_blank"><strong>demo</strong></a> how it works and looks here.</p>
<p>Here is the idea how we get the points on <strong>Eclipse</strong> using trigonametry. You can apply this formula to any programming language.</p>
<p>x=centerX+Xradius*Math.sin(angle);<br />
y=centerY+Yradius*Math.cos(angle );</p>
<p>Here is the function that will return the array of points exists on Eclipse. It will take five parameters ,<strong>centerx</strong>,<strong>centery</strong> , <strong>xradius</strong>,<strong>yradius</strong>,number of <strong>points</strong> we need.
</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> getCirclePoints<span style="color: #009900;">&#40;</span>centerX<span style="color: #339933;">,</span>centerY<span style="color: #339933;">,</span>xradius<span style="color: #339933;">,</span>yradius<span style="color: #339933;">,</span>segments<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #003366; font-weight: bold;">var</span> totalPoints<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span><span style="color: #009900;">&#40;</span>segments<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
x<span style="color: #339933;">=</span>centerX<span style="color: #339933;">+</span>xradius<span style="color: #339933;">*</span>Math.<span style="color: #660066;">sin</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">*</span><span style="color: #CC0000;">2</span><span style="color: #339933;">*</span>Math.<span style="color: #660066;">PI</span><span style="color: #339933;">/</span>segments<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
y<span style="color: #339933;">=</span>centerY<span style="color: #339933;">+</span>yradius<span style="color: #339933;">*</span>Math.<span style="color: #660066;">cos</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">*</span><span style="color: #CC0000;">2</span><span style="color: #339933;">*</span>Math.<span style="color: #660066;">PI</span><span style="color: #339933;">/</span>segments <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
totalPoints.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'x'</span><span style="color: #339933;">:</span>x<span style="color: #339933;">,</span><span style="color: #3366CC;">'y'</span><span style="color: #339933;">:</span>y<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">return</span> totalPoints<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><a href="http://demo.maheshchari.com/draweclipse/example3.html" target="_blank"><strong>Demo</strong></a></p>
<p>Animation Effect with above function</p>
<p><a href="http://demo.maheshchari.com/draweclipse/example2.html" target="_blank"><strong>Animation Demo</strong></a></p>
<img src="http://www.maheshchari.com/?ak_action=api_record_view&id=592&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.maheshchari.com/draw-eclipse-using-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>javascript function exists</title>
		<link>http://www.maheshchari.com/javascript-function-exists/</link>
		<comments>http://www.maheshchari.com/javascript-function-exists/#comments</comments>
		<pubDate>Sun, 19 Dec 2010 01:06:18 +0000</pubDate>
		<dc:creator>mahesh chari</dc:creator>
				<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.maheshchari.com/?p=589</guid>
		<description><![CDATA[Detect if a function exists in Javascript It is comman practice we call a call back functions in our javascript application ,we know that calling a non existed javascript function triggers a error. In order to overcome these kind of errors we must check that function exists and call only if that exists. Generelly every [...]]]></description>
			<content:encoded><![CDATA[<h2>Detect if a function exists in Javascript<br />
</h2>
<p>It is comman practice we call a <strong>call back</strong> functions in our javascript application ,we know that calling a non existed javascript function triggers a error. In order to overcome these kind of errors we must check that function exists and call only if that exists.</p>
<p>Generelly every function has scope in <strong>window</strong> object of browsers unless classes,objects instances. </p>
<h2>Example:</h2>
<p>function myfunction (){</p>
<p>var foo;</p>
<p>}</p>
<p>now this <strong>function</strong> defination can be collected in in <strong>window</strong> scope.</p>
<p>We check if this <strong>function</strong> defined using a simple <strong>IF</strong> condition as below.</p>
<p>if(window.myfunction){</p>
<p>}else{</p>
<p>}</p>
<p>Above will return true even it is function or a variable, so we have confine the condition to exactly is it function or not.</p>
<p>as below</p>
<p>if( typeof myfunction===&quot;function&quot;){</p>
<p>}else{</p>
<p>}</p>
<p>Javascript <strong>function</strong> is also a <strong>Object</strong> ,we can check for its instance kind is Base <strong>function</strong> prototype.</p>
<p>if( myfunction <strong>instanceof</strong>  Function){</p>
<p>}else {</p>
<p>}</p>
<p>Above <strong>methods</strong> works if only we get perticular function know, in our dynamic applications we have to check at run time and we don&#8217;t know exactly the name of the <strong>function</strong>. So we make a small <strong>function</strong> that will do for us.</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> function_exists <span style="color: #009900;">&#40;</span>function_name<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> function_name <span style="color: #339933;">===</span> <span style="color: #3366CC;">'string'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
     <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> window<span style="color: #009900;">&#91;</span>function_name<span style="color: #009900;">&#93;</span> <span style="color: #339933;">===</span> <span style="color: #3366CC;">'function'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span>function_name <span style="color: #000066; font-weight: bold;">instanceof</span> <span style="color: #003366; font-weight: bold;">Function</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>In above <strong>function</strong> the parameter can be string or a direct <strong>function</strong> reference. first we check if given parameter is string , then we check the function in the window scope.if given paramenter is direct function reference we check that it is <strong>instace</strong> of <strong>function</strong> prototype.</p>
<img src="http://www.maheshchari.com/?ak_action=api_record_view&id=589&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.maheshchari.com/javascript-function-exists/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>draw circle with javascript</title>
		<link>http://www.maheshchari.com/draw-circle-with-javascript/</link>
		<comments>http://www.maheshchari.com/draw-circle-with-javascript/#comments</comments>
		<pubDate>Thu, 09 Dec 2010 21:21:40 +0000</pubDate>
		<dc:creator>mahesh chari</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.maheshchari.com/?p=584</guid>
		<description><![CDATA[How to draw a Circle using HTML 4, CSS2,Javascript ,jQuery here we learn how to draw a basic circle with HTML div, CSS2, jQuery . Basic concept behind this scenario is Maths . We must know some basic circle equation to find the x, y co ordintates of the cicle perimeter. any point on circle [...]]]></description>
			<content:encoded><![CDATA[<h2>How to draw a Circle using HTML 4, CSS2,Javascript ,jQuery</h2>
<p>here we learn how to draw a basic circle with HTML div, CSS2, jQuery . Basic concept behind this scenario is Maths . </p>
<p>We must know some basic circle equation to find the x, y co ordintates of the cicle perimeter. any point on circle can be denoted as trigonametry equation as shown below. here Javascript function accepts in radians. next how many points we need to draw the circle ,we can draw as many points we want. </p>
<p>Concept : </p>
<p>x=centerX+radius*Math.sin(angle);<br />
  y=centerY+radius*Math.cos(angle);</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> getCirclePoints<span style="color: #009900;">&#40;</span>centerX<span style="color: #339933;">,</span>centerY<span style="color: #339933;">,</span>radius<span style="color: #339933;">,</span>segments<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #003366; font-weight: bold;">var</span> totalPoints<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>segments<span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
x<span style="color: #339933;">=</span>centerX<span style="color: #339933;">+</span>radius<span style="color: #339933;">*</span>Math.<span style="color: #660066;">sin</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">*</span><span style="color: #CC0000;">2</span><span style="color: #339933;">*</span>Math.<span style="color: #660066;">PI</span><span style="color: #339933;">/</span>segments<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
y<span style="color: #339933;">=</span>centerY<span style="color: #339933;">+</span>radius<span style="color: #339933;">*</span>Math.<span style="color: #660066;">cos</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">*</span><span style="color: #CC0000;">2</span><span style="color: #339933;">*</span>Math.<span style="color: #660066;">PI</span><span style="color: #339933;">/</span>segments<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
totalPoints.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'x'</span><span style="color: #339933;">:</span>x<span style="color: #339933;">,</span><span style="color: #3366CC;">'y'</span><span style="color: #339933;">:</span>y<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">return</span> totalPoints<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>&nbsp;</p>
<p>In the above function we decide how many points or segments we need. we should give radius and center point of the circle. </p>
<h2><a href="http://demo.maheshchari.com/drawcircle/example.html">Click Demo how it works instntly.</a></h2>
<h2><a href="http://demo.maheshchari.com/drawcircle/example1.html">See the animation effect with above function</a></h2>
<img src="http://www.maheshchari.com/?ak_action=api_record_view&id=584&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.maheshchari.com/draw-circle-with-javascript/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>detect user is active or idle on web page</title>
		<link>http://www.maheshchari.com/detect-user-is-active-or-idle-on-web-page/</link>
		<comments>http://www.maheshchari.com/detect-user-is-active-or-idle-on-web-page/#comments</comments>
		<pubDate>Thu, 25 Nov 2010 04:16:03 +0000</pubDate>
		<dc:creator>mahesh chari</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.maheshchari.com/?p=563</guid>
		<description><![CDATA[How to find the user is idle or active on web page or its element. We know that user is active on our web page or any element of the web page when he performs following actions Mouse Moves Key board button presses (presse down or up) Mouse Wheel or Mouse Scrolls Mouse Down ( [...]]]></description>
			<content:encoded><![CDATA[<h2>How to find the user is idle or active on web page or its element.</h2>
<p><img src="http://www.maheshchari.com/wp-content/uploads/2010/11/idletimer.jpg" alt="" title="How to detect the user idle activity on web page using jquery" width="500" height="271" class="aligncenter size-full wp-image-566" /></p>
<p>We know that user is active on our web page or any element of the web page when he performs following actions </p>
<ul>
<li>Mouse Moves</li>
<li>Key board button presses (presse down or up) </li>
<li>Mouse Wheel or Mouse Scrolls</li>
<li>Mouse Down ( click)  </li>
</ul>
<p>When the user doesn&#8217;t do any of above action on web page ,he is idle or in active. </p>
<p>Here we group above events as <strong>user active events</strong> and other one event that is user <strong>idle Event</strong>. let consider user is idle for a certain time if he doesn&#8217;t any user events ,<strong>10 seconds</strong> .</p>
<p>The logic is here very simple we bind a timer event that is called <strong>idle event</strong> ,it will called 10seconds. </p>
<p>If we user performs any above user active events ,we post pone the <strong>idle event</strong> for next 10seconds. </p>
<p>If he doesn&#8217;t do any thing for 10seconds the idle event automatically called by<strong> timer event</strong>. </p>
<p>We test on following Element with jQuery. </p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> timer<span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">// a timer event</span>
<span style="color: #003366; font-weight: bold;">var</span> idleTime<span style="color: #339933;">=</span><span style="color: #CC0000;">3000</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">//ms</span>
<span style="color: #006600; font-style: italic;">//this function post pones calling userIdle function for next 10 Seconds</span>
<span style="color: #003366; font-weight: bold;">function</span> userActive<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
clearTimeout<span style="color: #009900;">&#40;</span>timer<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">//resent the timer </span>
timer<span style="color: #339933;">=</span>setTimeout<span style="color: #009900;">&#40;</span>userIdle<span style="color: #339933;">,</span>idleTime<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">//again post pone user Idle function</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#ObserverElement'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Glad to see you again !!'</span><span style="color: #009900;">&#41;</span>
.<span style="color: #660066;">trigger</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'active'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">// trigger a custome event that is user active</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">function</span> userIdle<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#ObserverElement'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Oops!! user in active !!'</span><span style="color: #009900;">&#41;</span>
.<span style="color: #660066;">trigger</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'idle'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">// trigger a custom event that is user is idle.</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
$<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#ObserverElement'</span><span style="color: #009900;">&#41;</span>
.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'mousemove'</span><span style="color: #339933;">,</span>userActive<span style="color: #009900;">&#41;</span>
.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'keydown'</span><span style="color: #339933;">,</span>userActive<span style="color: #009900;">&#41;</span>
.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'DOMMouseScroll'</span><span style="color: #339933;">,</span>userActive<span style="color: #009900;">&#41;</span>
.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'mousewheel'</span><span style="color: #339933;">,</span>userActive<span style="color: #009900;">&#41;</span>
.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'mousedown'</span><span style="color: #339933;">,</span>userActive<span style="color: #009900;">&#41;</span>
.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'active'</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">//if user comes active again we change back ground color</span>
$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'background-color'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'#FFFF00'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'idle'</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #006600; font-style: italic;">//if user go in active or idel we change back ground color</span>
$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'background-color'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'#CCFF00'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h2><a href='http://www.maheshchari.com/wp-content/uploads/2010/11/idletime.zip'>Download Demo</a></h2>
<img src="http://www.maheshchari.com/?ak_action=api_record_view&id=563&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.maheshchari.com/detect-user-is-active-or-idle-on-web-page/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Serve your PHP file as JavaScript file</title>
		<link>http://www.maheshchari.com/serve-your-php-file-as-javascript-file/</link>
		<comments>http://www.maheshchari.com/serve-your-php-file-as-javascript-file/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 17:23:17 +0000</pubDate>
		<dc:creator>mahesh chari</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[PHP/mysql]]></category>

		<guid isPermaLink="false">http://www.maheshchari.com/?p=523</guid>
		<description><![CDATA[Serve Your PHP script as JavaScript file. Some times we need to serve user based JavaScript files, for example passing your php variables to JavaScript on client side of browser. protecting JavaScript variables. setting browser cache manually for JavaScript files. loading user based java script files. for easy versification of your JavaScript files. Download Demo [...]]]></description>
			<content:encoded><![CDATA[<h1>Serve Your PHP script as JavaScript file.</h1>
<p>Some times we need to serve user based JavaScript files, for example</p>
<ul>
<li>passing your php variables to JavaScript on client side of browser.</li>
<li>protecting JavaScript variables.</li>
<li>setting browser cache manually for JavaScript files.</li>
<li>loading user based java script files.</li>
<li>for easy versification of your JavaScript files.</li>
</ul>
<h3><a href='http://www.maheshchari.com/wp-content/uploads/2010/03/wp.zip'>Download Demo</a></h3>
<p>Suppose your php-javascript file &#8220;<b>my-phpjavascript.js.php</b>&#8221; ,now you can add this file as below example.</p>
<h3>Client HTML code</h3>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;html&gt;
&lt;head&gt;
&lt;script  type=&quot;text/javascript&quot; src=&quot;my-phpjavascript.js.php&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;script&gt;
alert(site_name);
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></div></div>

<h3>my-phpjavascript.js.php code</h3>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #666666; font-style: italic;">// this is PHP variable</span>
<span style="color: #000088;">$sitename</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;My PHP development blog.&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
//this is javascript variable 
var site_name=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$sitename</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;;</pre></div></div>

<p>some browsers don&#8217;t recognize this php file as javascript ,so to make all browser compatibility we have to send javascript headers to browser ,we can do that by adding a few line of code at starting of php script. </p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;Content-Type: text/javascript; charset=utf-8&quot;</span>  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Remember to preview this code you must installed PHP</p>
<h3><a href='http://www.maheshchari.com/wp-content/uploads/2010/03/wp.zip'>Download Demo</a></h3>
<img src="http://www.maheshchari.com/?ak_action=api_record_view&id=523&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.maheshchari.com/serve-your-php-file-as-javascript-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>prevent iframe ,frame theft</title>
		<link>http://www.maheshchari.com/prevent-iframe-frame-theft/</link>
		<comments>http://www.maheshchari.com/prevent-iframe-frame-theft/#comments</comments>
		<pubDate>Sun, 31 Jan 2010 09:56:17 +0000</pubDate>
		<dc:creator>mahesh chari</dc:creator>
				<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.maheshchari.com/?p=404</guid>
		<description><![CDATA[How to stop iframe, frame thefts of our site resources. Sites like Google Image search , goodphptutorials.com and phpcamp.net displays the website under the IFRAME .No one want their site to be displayed it under the IFRAME, FRAMES. If you want to protect your site to be displayed under the IFRAME,FRAMES then just copy and [...]]]></description>
			<content:encoded><![CDATA[<h1>How to stop iframe, frame thefts of our site resources.</h1>
<p>Sites like Google Image search , goodphptutorials.com and phpcamp.net displays the  website under the IFRAME .No one want their site to  be displayed it under the IFRAME, FRAMES. If you want to protect your site to  be displayed under the IFRAME,FRAMES then just copy and paste below javascript code after body tag.</p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">top</span> <span style="color: #339933;">!==</span> window.<span style="color: #660066;">self</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
document.<span style="color: #000066; font-weight: bold;">write</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">;</span>
window.<span style="color: #660066;">top</span>.<span style="color: #660066;">location</span> <span style="color: #339933;">=</span> window.<span style="color: #660066;">self</span>.<span style="color: #660066;">location</span><span style="color: #339933;">;</span> setTimeout<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>document.<span style="color: #660066;">body</span>.<span style="color: #660066;">innerHTML</span><span style="color: #339933;">=</span><span style="color: #3366CC;">''</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
window.<span style="color: #660066;">self</span>.<span style="color: #000066;">onload</span><span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>evt<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
document.<span style="color: #660066;">body</span>.<span style="color: #660066;">innerHTML</span><span style="color: #339933;">=</span><span style="color: #3366CC;">''</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Here we use simple logic that we check our page document window is main window or not. if our document isn&#8217;t in main window it might be in iframe or frame. then we switch the location of main window to our existing document locations.  Before doing this redirection we make the document empty, because the imposter can break this code before loading . </p>
<img src="http://www.maheshchari.com/?ak_action=api_record_view&id=404&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.maheshchari.com/prevent-iframe-frame-theft/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery ajaxstart ajaxstop</title>
		<link>http://www.maheshchari.com/jquery-ajaxstart-ajaxstop/</link>
		<comments>http://www.maheshchari.com/jquery-ajaxstart-ajaxstop/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 11:14:48 +0000</pubDate>
		<dc:creator>mahesh chari</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.maheshchari.com/?p=393</guid>
		<description><![CDATA[Displaying Ajax started element using JQuery ajaxstart,ajaxstop jQuery is most famous javascript library compared to its concurrents. One of importent functionality in jQuery is its Ajax handling. It has very flexible methods for Ajax.We seen how to handle the Ajax Errors in my previous Article.Here we concentrate on jQuery ajaxstart,ajaxstop default methods to handle globally. [...]]]></description>
			<content:encoded><![CDATA[<h2>Displaying Ajax started element using JQuery ajaxstart,ajaxstop</h2>
<p>jQuery is most famous javascript library compared to its concurrents. One of importent functionality in jQuery is its Ajax handling. It has very flexible methods for Ajax.We seen how to handle the Ajax Errors in my previous Article.Here we concentrate on jQuery ajaxstart,ajaxstop default methods to handle globally. </p>
<p>Present it is very common to use ajax for every functionality,while querying externel resources with ajax we have to show the end user there is something happening behind the page.Some novice users don&#8217;t know about this functionality. So we must intimate the end user we are working on back end. Some times Ajax calls takes more time to respond with some reason. in that case most users confused about it may be stopped working . so here we take one example and tutorial.</p>
<h3>ajaxStart</h3>
<p>This method is called globally by jQuery while before starting any ajax call starts.</p>
<h3>ajaxstop</h3>
<p>This method called after stopping the Ajax stopped successfully or Ajax call cancelled.</p>
<p>These methods called on $.getJSON,$.get,$.post,$().load,$.getScript function.</p>
<h3>Example</h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="javacript" style="font-family:monospace;">jQuery().ready(function(){ //Dom ready 
$('#loadimg').ajaxStart(function(){$(this).show();});//this method for ajax start		
$('#loadimg').ajaxStop(function(){$(this).hide();});//this method for ajax stop
$('#loadjson').click(function(){
$.getJSON('ajax.js',function(d){alert(d.name);});//$.getJSON method
});
$('#loadelement').click(function(){$(this).load('loadsnippet.html')});//load method
});</pre></td></tr></table></div>

<p><a href="http://www.maheshchari.com">Try more examples</a></p>
<p>&nbsp;</p>
<p><a href='http://www.maheshchari.com/wp-content/uploads/2010/01/ajaxstart.zip'>Demo Download</a></p>
<img src="http://www.maheshchari.com/?ak_action=api_record_view&id=393&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.maheshchari.com/jquery-ajaxstart-ajaxstop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>hide javascript code from non javascript browser</title>
		<link>http://www.maheshchari.com/hide-javascript-code-from-non-javascript-browser/</link>
		<comments>http://www.maheshchari.com/hide-javascript-code-from-non-javascript-browser/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 03:14:42 +0000</pubDate>
		<dc:creator>mahesh chari</dc:creator>
				<category><![CDATA[Html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[browser]]></category>

		<guid isPermaLink="false">http://www.maheshchari.com/?p=368</guid>
		<description><![CDATA[hide JavaScript code from non-JavaScript browsers Here we learn how to hide the javascript code from non javascript browsers , javascript disabled browsers and mobile browsers .Non javascript browsers renders the javascript code as generel text without exucuting the code. So we must aware how to hide the javascript from these browsers. &#160; 1 2 [...]]]></description>
			<content:encoded><![CDATA[<h1>hide JavaScript code from non-JavaScript  browsers</h1>
<p>Here we learn how to hide the javascript code from non javascript browsers , javascript disabled browsers and mobile browsers .Non javascript browsers renders the javascript code as generel text without exucuting the code. So we must aware how to hide the javascript from these browsers.</p>
<p>&nbsp; </p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;!--</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;This alert box is hidden from non javascript browsers.!!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">//--&gt;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<img src="http://www.maheshchari.com/?ak_action=api_record_view&id=368&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.maheshchari.com/hide-javascript-code-from-non-javascript-browser/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>check browser java enabled</title>
		<link>http://www.maheshchari.com/check-browser-java-enabled/</link>
		<comments>http://www.maheshchari.com/check-browser-java-enabled/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 11:48:33 +0000</pubDate>
		<dc:creator>mahesh chari</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[browser]]></category>

		<guid isPermaLink="false">http://www.maheshchari.com/?p=338</guid>
		<description><![CDATA[Check Browser Java application enabled Java is a high-level, third generation programming language, like C and many others.Java allows you to play online games, chat with people around the world, calculate your mortgage interest, and view images in 3D, just to name a few. It&#8217;s also integral to the intranet applications and other e-business solutions [...]]]></description>
			<content:encoded><![CDATA[<h1>Check Browser Java application enabled<br />
</h1>
<p><strong>Java</strong>  is a high-level, third generation  programming language, like C and many  others.<strong>Java</strong> allows you to play online games, chat with people around the  world, calculate your mortgage interest, and view images in 3D, just to  name a few. It&#8217;s also integral to the intranet applications and other  e-business solutions that are the foundation of corporate computing.<br />
  With some reasons the web browser don&rsquo;t support <strong>Javas</strong> ,like user intentially disables,some browsers don&rsquo;t support.Then we must check the whether user&rsquo;s web browser has<strong> Java</strong> enabled.Here we discuss how to handle <strong>non Java browser</strong>. </p>
<h3>We show normal warning message with javascript. </h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script<span style="color: #339933;">&gt;</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>navigator.<span style="color: #660066;">javaEnabled</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Java Enabled.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">//we do our normal action</span>
<span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Java Disabled.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">//we warn the user to download or other </span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<h3>We redirect the user to seperate UI or seperate <strong>sub domain</strong> that handles for non <strong>java browser</strong>.</h3>
<p>&nbsp; </p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script<span style="color: #339933;">&gt;</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>navigator.<span style="color: #660066;">javaEnabled</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Java Enabled.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">//we do our normal action</span>
<span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
document.<span style="color: #660066;">location</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;nonjava-html-page.html&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<img src="http://www.maheshchari.com/?ak_action=api_record_view&id=338&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.maheshchari.com/check-browser-java-enabled/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>check javascript disabled</title>
		<link>http://www.maheshchari.com/check-javascript-disabled/</link>
		<comments>http://www.maheshchari.com/check-javascript-disabled/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 03:09:42 +0000</pubDate>
		<dc:creator>mahesh chari</dc:creator>
				<category><![CDATA[Html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[browser]]></category>

		<guid isPermaLink="false">http://www.maheshchari.com/?p=326</guid>
		<description><![CDATA[Check Browser Javascript enabled JavaScript is a small, lightweight, object-oriented, cross-platform scripting language.JavaScript is used in millions of Web pages to add functionality, validate forms, detect browsers, and much more.With some reasons the web browser don&#8217;t support Javascript ,like user intentially disables,some mobile browsers version don&#8217;t support.Then it must we check the whether user&#8217;s web [...]]]></description>
			<content:encoded><![CDATA[<h1>Check Browser Javascript enabled</h1>
<p><strong>JavaScript</strong> is a small, lightweight, object-oriented, cross-platform scripting language.JavaScript is used in millions of Web pages to add functionality, validate forms, detect browsers, and much more.With some reasons the web browser don&#8217;t support <strong>Javascript</strong> ,like user<strong> intentially disables</strong>,some  <strong>mobile browsers</strong>  version don&#8217;t support.Then it must we check the whether user&#8217;s web browser has Javascript enabled.Here we discuss how to <strong>handle non Javascript browser</strong>.</p>
<p>We show a alert ,<strong>warning message</strong> if user browser don&#8217;t hav Javascript enabled.using <strong>&lt;noscript&gt;</strong> HTML tag. just add bellow code to any where in the <strong>body </strong>section.<strong>&lt;noscript&gt;</strong> element will be rendered by those <strong>Javascript disabled</strong> browsers. </p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;noscript&gt;&lt;font face=arial&gt;JavaScript must be enabled in order for you to use maheshchari.com in standard view. However, it seems JavaScript is either disabled or not supported by your browser. To use standard view, enable JavaScript by changing your browser options, then &lt;a href=&quot;&quot;&gt;try again&lt;/a&gt;. &lt;/font&gt;&lt;/noscript&gt;</pre></td></tr></table></div>

<p>We show a alert ,warning message with Javascript itself if user browser <strong>doesn&#8217;t support &lt;noscript&gt;</strong> HTML tag.below example code demonstrates.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;div id=&quot;nojs&quot;&gt;&lt;font face=arial&gt;JavaScript must be enabled in order for you to use maheshchari.com in standard view. However, it seems JavaScript is either disabled or not supported by your browser. To use standard view, enable JavaScript by changing your browser options, then &lt;a href=&quot;&quot;&gt;try again&lt;/a&gt;.&lt;/font&gt;&lt;/div&gt;
&lt;script&gt;
//if script enabled warning message hidden.
document.getElementById('nojs').style.display=&quot;none&quot;;
&lt;/script&gt;</pre></td></tr></table></div>

<p>&nbsp;</p>
<p>We create <strong>seperate UI</strong> or <strong>seperate web site</strong> for those <strong>Javascript disabled</strong> browsers. below example redirects the user automatically if <strong>Javascript disabled.</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;html&gt;
&lt;head&gt;
&lt;noscript&gt;
&lt;meta http-equiv=&quot;refresh&quot; content=&quot;0;URL=http://mobile.maheshchari.com&quot; /&gt;
&lt;/noscript&gt;
&lt;/head&gt;
&lt;body&gt;&lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<p>&nbsp; </p>
<img src="http://www.maheshchari.com/?ak_action=api_record_view&id=326&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.maheshchari.com/check-javascript-disabled/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

