<?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>Latest-Tutorial &#187; internet explorer</title>
	<atom:link href="http://latest-tutorial.com/tag/internet-explorer/feed/" rel="self" type="application/rss+xml" />
	<link>http://latest-tutorial.com</link>
	<description>Best Tutorials for Beginners of Java,Android,JavaScript,Asp.net,Objective C,C-Sharp and many other topics.We have experts tutorial material against these topics.</description>
	<lastBuildDate>Wed, 12 Jun 2013 13:57:34 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>HTML5 Canvas</title>
		<link>http://latest-tutorial.com/2013/04/05/html5-canvas/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=html5-canvas</link>
		<comments>http://latest-tutorial.com/2013/04/05/html5-canvas/#comments</comments>
		<pubDate>Fri, 05 Apr 2013 11:57:34 +0000</pubDate>
		<dc:creator>Zeeshan Akhter</dc:creator>
				<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Canvas element]]></category>
		<category><![CDATA[Cascading Style Sheets]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Gradient]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Opera]]></category>

		<guid isPermaLink="false">http://latest-tutorial.com/?p=2618</guid>
		<description><![CDATA[The &#60;canvas&#62; element is used to draw graphics, on the fly, on a web page. Draw a red rectangle, a gradient rectangle, a multicolor rectangle, and some multicolor text onto the canvas: What is Canvas? The HTML5 &#60;canvas&#62; element is used to draw graphics, on the fly, via scripting (usually JavaScript). The &#60;canvas&#62; element is [...]]]></description>
				<content:encoded><![CDATA[<div class="page-restrict-output"><div style="padding-left:5px; padding-right:5px; padding-bottom:5px; padding-top:5px; margin-left:auto; margin-right:auto; ">
<script type="text/javascript"><!--
google_ad_client = "pub-1265735558479661";
google_ad_width = 468;
google_ad_height = 60;
google_color_border = "FFFFFF";
google_color_link = "E895CC";
google_color_text = "000000";
google_color_bg = "FFFFFF";
google_color_url = "0066CC";
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<p>The &lt;canvas&gt; element is used to draw graphics, on the fly, on a web page.</p>
<p>Draw a red rectangle, a gradient rectangle, a multicolor rectangle, and some multicolor text onto the canvas:</p>
<hr />
<h2>What is Canvas?</h2>
<p>The HTML5 &lt;canvas&gt; element is used to draw graphics, on the fly, via scripting (usually JavaScript).</p>
<p>The &lt;canvas&gt; element is only a container for graphics. You must use a script to actually draw the graphics.</p>
<p>Canvas has several methods for drawing paths, boxes, circles, characters, and adding images.</p>
<hr />
<h2>Browser Support</h2>
<p><img title="Internet Explorer" alt="Internet Explorer" src="http://i0.wp.com/latest-tutorial.com/wp-content/uploads/2013/04/compatible_ie.gif?resize=31%2C30" data-recalc-dims="1" /><img title="Firefox" alt="Firefox" src="http://i1.wp.com/latest-tutorial.com/wp-content/uploads/2013/04/compatible_firefox.gif?resize=31%2C30" data-recalc-dims="1" /><img title="Opera" alt="Opera" src="http://i1.wp.com/latest-tutorial.com/wp-content/uploads/2013/04/compatible_opera.gif?resize=28%2C30" data-recalc-dims="1" /><img title="Google Chrome" alt="Google Chrome" src="http://i2.wp.com/latest-tutorial.com/wp-content/uploads/2013/04/compatible_chrome.gif?resize=31%2C30" data-recalc-dims="1" /><img title="Safari" alt="Safari" src="http://i1.wp.com/latest-tutorial.com/wp-content/uploads/2013/04/compatible_safari.gif?resize=28%2C30" data-recalc-dims="1" /></p>
<p>Internet Explorer 9+, Firefox, Opera, Chrome, and Safari support the &lt;canvas&gt; element.</p>
<p><b>Note:</b> Internet Explorer 8 and earlier versions, do not support the &lt;canvas&gt; element.</p>
<hr />
<h2>Create a Canvas</h2>
<p>A canvas is a rectangular area on an HTML page, and it is specified with the &lt;canvas&gt; element.</p>
<p><b>Note:</b> By default, the &lt;canvas&gt; element has no border and no content.</p>
<p>The markup looks like this:</p>
<div>
<div>&lt;canvas id=&#8221;myCanvas&#8221; width=&#8221;200&#8243; height=&#8221;100&#8243;&gt;&lt;/canvas&gt;</div>
</div>
<p><b>Note:</b> Always specify an id attribute (to be referred to in a script), and a width and height attribute to define the size of the canvas.</p>
<p><b>Tip:</b> You can have multiple &lt;canvas&gt; elements on one HTML page.</p>
<p>To add a border, use the style attribute:</p>
<div>
<h2>Example</h2>
<div>&lt;canvas id=&#8221;myCanvas&#8221; width=&#8221;200&#8243; height=&#8221;100&#8243;<br />
style=&#8221;border:1px solid #000000;&#8221;&gt;<br />
&lt;/canvas&gt;</div>
</div>
<hr />
<h2>Draw Onto The Canvas With JavaScript</h2>
<p>All drawing on the canvas must be done inside a JavaScript:</p>
<div>
<h2>Example</h2>
<div>&lt;script&gt;<br />
var c=document.getElementById(&#8220;myCanvas&#8221;);<br />
var ctx=c.getContext(&#8220;2d&#8221;);<br />
ctx.fillStyle=&#8221;#FF0000&#8243;;<br />
ctx.fillRect(0,0,150,75);<br />
&lt;/script&gt;</div>
</div>
<p><b>Example explained:</b></p>
<p>First, find the &lt;canvas&gt; element:</p>
<div>
<div>var c=document.getElementById(&#8220;myCanvas&#8221;);</div>
</div>
<p>Then, call its getContext() method (you must pass the string &#8220;2d&#8221; to the getContext() method):</p>
<div>
<div>var ctx=c.getContext(&#8220;2d&#8221;);</div>
</div>
<p>The getContext(&#8220;2d&#8221;) object is a built-in HTML5 object, with many properties and methods for drawing paths, boxes, circles, text, images, and more.</p>
<p>The next two lines draw a red rectangle:</p>
<div>
<div>ctx.fillStyle=&#8221;#FF0000&#8243;;<br />
ctx.fillRect(0,0,150,75);</div>
</div>
<p>The fillStyle property can be a CSS color, a gradient, or a pattern. The default fillStyle is #000000 (black).</p>
<p>The fillRect(<i>x,y,width,height</i>) method draws a rectangle filled with the current fill style.</p>
<hr />
<h2>Canvas Coordinates</h2>
<p>The canvas is a two-dimensional grid.</p>
<p>The upper-left corner of the canvas has coordinate (0,0)</p>
<p>So, the fillRect() method above had the parameters (0,0,150,75).</p>
<p>This means: Start at the upper-left corner (0,0) and draw a 150&#215;75 pixels rectangle.</p>
<p><b>Coordinates Example</b></p>
<p>Mouse over the rectangle below to see its x and y coordinates:</p>
<div>
<div>X</div>
<div>Y</div>
</div>
<hr />
<h2>Canvas &#8211; Paths</h2>
<p>To draw straight lines on a canvas, we will use the following two methods:</p>
<ul>
<li>moveTo(<i>x,y</i>) defines the starting point of the line</li>
<li>lineTo(<i>x,y</i>) defines the ending point of the line</li>
</ul>
<p>To actually draw the line, we must use one of the &#8220;ink&#8221; methods, like stroke().</p>
<div>
<h2>Example</h2>
<p>Define a starting point in position (0,0), and an ending point in position (200,100). Then use the stroke() method to actually draw the line:</p>
<p>JavaScript:</p>
<div>var c=document.getElementById(&#8220;myCanvas&#8221;);<br />
var ctx=c.getContext(&#8220;2d&#8221;);<br />
ctx.moveTo(0,0);<br />
ctx.lineTo(200,100);<br />
ctx.stroke();</div>
</div>
<p>To draw a circle on a canvas, we will use the following method:</p>
<ul>
<li>arc(x,y,r,start,stop)</li>
</ul>
<p>To actually draw the circle, we must use one of the &#8220;ink&#8221; methods, like stroke() or fill().</p>
<div>
<h2>Example</h2>
<p>Create a circle with the arc() method:</p>
<p>JavaScript:</p>
<div>var c=document.getElementById(&#8220;myCanvas&#8221;);<br />
var ctx=c.getContext(&#8220;2d&#8221;);<br />
ctx.beginPath();<br />
ctx.arc(95,50,40,0,2*Math.PI);<br />
ctx.stroke();</div>
</div>
<hr />
<h2>Canvas &#8211; Text</h2>
<p>To draw text on a canvas, the most important property and methods are:</p>
<ul>
<li>font &#8211; defines the font properties for text</li>
<li>fillText(<i>text,x,y</i>) &#8211; Draws &#8220;filled&#8221; text on the canvas</li>
<li>strokeText(<i>text,x,y</i>) &#8211; Draws text on the canvas (no fill)</li>
</ul>
<p>Using fillText():</p>
<div>
<h2>Example</h2>
<p>Write a 30px high filled text on the canvas, using the font &#8220;Arial&#8221;:</p>
<p>JavaScript:</p>
<div>var c=document.getElementById(&#8220;myCanvas&#8221;);<br />
var ctx=c.getContext(&#8220;2d&#8221;);<br />
ctx.font=&#8221;30px Arial&#8221;;<br />
ctx.fillText(&#8220;Hello World&#8221;,10,50);</div>
</div>
<p>Using strokeText():</p>
<div>
<h2>Example</h2>
<p>Write a 30px high text (no fill) on the canvas, using the font &#8220;Arial&#8221;:</p>
<p>JavaScript:</p>
<div>var c=document.getElementById(&#8220;myCanvas&#8221;);<br />
var ctx=c.getContext(&#8220;2d&#8221;);<br />
ctx.font=&#8221;30px Arial&#8221;;<br />
ctx.strokeText(&#8220;Hello World&#8221;,10,50);</div>
</div>
<hr />
<h2>Canvas &#8211; Gradients</h2>
<p>Gradients can be used to fill rectangles, circles, lines, text, etc. Shapes on the canvas are not limited to solid colors.</p>
<p>There are two different types of gradients:</p>
<ul>
<li>createLinearGradient(<i>x,y,x1,y1</i>) &#8211; Creates a linear gradient</li>
<li>createRadialGradient(<i>x,y,r,x1,y1,r1</i>) &#8211; Creates a radial/circular gradient</li>
</ul>
<p>Once we have a gradient object, we must add two or more color stops.</p>
<p>The addColorStop() method specifies the color stops, and its position along the gradient. Gradient positions can be anywhere between 0 to 1.</p>
<p>To use the gradient, set the fillStyle or strokeStyle property to the gradient, and then draw the shape, like a rectangle, text, or a line.</p>
<p>Using createLinearGradient():</p>
<div>
<h2>Example</h2>
<p>Create a linear gradient. Fill rectangle with the gradient:</p>
<p>JavaScript:</p>
<div>var c=document.getElementById(&#8220;myCanvas&#8221;);<br />
var ctx=c.getContext(&#8220;2d&#8221;);</p>
<p>// Create gradient<br />
var grd=ctx.createLinearGradient(0,0,200,0);<br />
grd.addColorStop(0,&#8221;red&#8221;);<br />
grd.addColorStop(1,&#8221;white&#8221;);</p>
<p>// Fill with gradient<br />
ctx.fillStyle=grd;<br />
ctx.fillRect(10,10,150,80);</p></div>
</div>
<p>Using createRadialGradient():</p>
<div>
<h2>Example</h2>
<p>Create a radial/circular gradient. Fill rectangle with the gradient:</p>
<p>JavaScript:</p>
<div>var c=document.getElementById(&#8220;myCanvas&#8221;);<br />
var ctx=c.getContext(&#8220;2d&#8221;);</p>
<p>// Create gradient<br />
var grd=ctx.createRadialGradient(75,50,5,90,60,100);<br />
grd.addColorStop(0,&#8221;red&#8221;);<br />
grd.addColorStop(1,&#8221;white&#8221;);</p>
<p>// Fill with gradient<br />
ctx.fillStyle=grd;<br />
ctx.fillRect(10,10,150,80);</p></div>
</div>
<hr />
<h2>Canvas &#8211; Images</h2>
<p>To draw an image on a canvas, we will use the following method:</p>
<ul>
<li>drawImage(<i>image,x,y</i>)</li>
</ul>
<div>
<h2>Image to use:</h2>
<p><img id="scream" alt="The Scream" src="http://i2.wp.com/latest-tutorial.com/wp-content/uploads/2013/04/img_the_scream.jpg" data-recalc-dims="1" /></p>
<h2>Example</h2>
<p>Draw the image onto the canvas:</p>
<p>JavaScript:</p>
<div>var c=document.getElementById(&#8220;myCanvas&#8221;);<br />
var ctx=c.getContext(&#8220;2d&#8221;);<br />
var img=document.getElementById(&#8220;scream&#8221;);<br />
ctx.drawImage(img,10,10);</div>
</div>
<hr />
<h2>HTML Canvas Reference</h2>
<p>For a complete reference of all the properties and methods that can be used with the Canvas object (with try-it examples on every property and method), go to our <a href="http://www.w3schools.com/tags/ref_canvas.asp">Canvas Reference.</a></p>
<h2>The HTML &lt;canvas&gt; Tag</h2>
<table>
<tbody>
<tr>
<th align="left" width="150">Tag</th>
<th align="left">Description</th>
</tr>
<tr>
<td><a href="http://www.w3schools.com/tags/tag_canvas.asp">&lt;canvas&gt;</a></td>
<td>Used to draw graphics, on the fly, via scripting (usually JavaScript)</td>
</tr>
</tbody>
</table>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Enhanced by Zemanta" href="http://www.zemanta.com/?px"><img class="zemanta-pixie-img" style="border: none; float: right;" alt="Enhanced by Zemanta" src="http://i0.wp.com/img.zemanta.com/zemified_e.png" data-recalc-dims="1" /></a></div>
<center><script type="text/javascript"><!--
google_ad_client = "pub-1265735558479661";
google_ad_width = 468;
google_ad_height = 60;
google_color_border = "FFFFFF";
google_color_link = "E895CC";
google_color_text = "000000";
google_color_bg = "FFFFFF";
google_color_url = "0066CC";
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></center>
</div>]]></content:encoded>
			<wfw:commentRss>http://latest-tutorial.com/2013/04/05/html5-canvas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>12 Tips to Maintain a Virus Free Computer</title>
		<link>http://latest-tutorial.com/2013/02/26/12-tips-to-maintain-a-virus-free-computer/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=12-tips-to-maintain-a-virus-free-computer</link>
		<comments>http://latest-tutorial.com/2013/02/26/12-tips-to-maintain-a-virus-free-computer/#comments</comments>
		<pubDate>Tue, 26 Feb 2013 07:18:18 +0000</pubDate>
		<dc:creator>Zeeshan Akhter</dc:creator>
				<category><![CDATA[Random Posts]]></category>
		<category><![CDATA[Antivirus]]></category>
		<category><![CDATA[Computer security]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Hotmail]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[Malware]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Windows Update]]></category>

		<guid isPermaLink="false">http://latest-tutorial.com/?p=2230</guid>
		<description><![CDATA[Is your computer infected with virus? Do you often get mysterious error messages? Well, this is a common problem faced by almost all the computer users across the globe. Even though some of them are harmless, they do have the ability to do a number of nasty things up to and including damaging or erasing sensitive [...]]]></description>
				<content:encoded><![CDATA[<div class="page-restrict-output"><p><img class="alignright" title="Tips to Maintain a Virus Free Computer" src="http://i1.wp.com/latest-tutorial.com/wp-content/uploads/2013/02/computer-virus.jpg?resize=145%2C140" alt="Tips to Maintain a Virus Free Computer" data-recalc-dims="1" />Is your computer infected with virus? Do you often get mysterious error messages? Well, this is a common problem faced by almost all the computer users across the globe.</p>
<p>Even though some of them are harmless, they do have the ability to do a number of nasty things up to and including damaging or erasing sensitive data from your computer. However, there are ways to keep viruses and other <a class="zem_slink" title="Malware" href="http://en.wikipedia.org/wiki/Malware" rel="wikipedia" target="_blank">malware</a> away from your computer. Here are the 12 tips to maintain a virus free computer:</p>
<ol>
<li>Email is one of the common ways by which your computer can catch a virus. So, it is always recommended to stay away from <strong>SPAM</strong>. Open only those emails that has it’s origin from a trusted source such as those which comes from your contact list.
<p>If you are using your own private email host (other than Gmail, Yahoo, <a class="zem_slink" title="Hotmail" href="http://www.hotmail.com" rel="homepage" target="_blank">Hotmail</a> etc.) then it is highly recommended that you use a good spam filter. And finally <strong>NEVER click</strong> on any links in the emails that comes from untrusted sources.</li>
<li><a class="zem_slink" title="USB" href="http://en.wikipedia.org/wiki/USB" rel="wikipedia" target="_blank">USB</a> thumb/pen drives is another common way by which viruses spread rapidly. So, it is always a good habit to perform a <a class="zem_slink" title="Antivirus software" href="http://en.wikipedia.org/wiki/Antivirus_software" rel="wikipedia" target="_blank">virus scan</a> before copying any data onto your computer. NEVER double-click the pen drive to open it. Instead right-click on it and select the option “open”. This is the safe way to open a pen drive.</li>
<li>Be careful about using <a class="zem_slink" title="Microsoft Outlook" href="http://www.microsoft.com/mac/outlook" rel="homepage" target="_blank">MS Outlook</a>. Outlook is more susceptible to worms than other e-mail programs, unless you have an efficient antivirus programs running. Use Pegasus or Thunderbird (by Mozilla), or a web-based program such as Hotmail or Yahoo (In Firefox).</li>
<li>As we all know, <a class="zem_slink" title="Internet" href="http://en.wikipedia.org/wiki/Internet" rel="wikipedia" target="_blank">Internet</a> is the main source of all malicious programs including viruses, worms, trojans etc. In fact, Internet contributes to virus infection by up to 80 percent. So, here are the tips for safe surfing habits so that you can ward off virus infection up to the maximum possible extent.
<ul>
<li>Do not click on pop-up windows that announce a sudden disaster in your city or announce that you’ve won an hourly prize. They are the ways to mislead Internet users and you should never trust them.</li>
<li>You can also use a <a class="zem_slink" title="Pop-up ad" href="http://en.wikipedia.org/wiki/Pop-up_ad" rel="wikipedia" target="_blank">pop-up blocker</a> to automatically block those pop-ups.</li>
</ul>
</li>
<li>Most of us use search engines like Google to find what we are looking for. It is quite obvious for a malicious website to get listed in the search results. So, in order to avoid visiting those untrusted malicious websites, you can download and install the <a href="http://linkscanner.avg.com/" rel="nofollow" target="_blank">AVG LinkScanner</a> which is a freeware. This tool can become very handy and will help you to stay away from those malicious websites.</li>
<li>Install a good antivirus software and keep it updated. Also perform full system scan periodically. It is highly recommended that you turn on the automatic update feature. This is the most essential task to protect your PC from viruses. If <a class="zem_slink" title="information security training" href="http://www.infosecinstitute.com" rel="infosec" target="_blank">PC security</a> is your first option then it is recommended that you go for a shareware antivirus software rather than using the freeware stuffs.
<p>Most of the antivirus programs offer the auto-protect feature that provides real-time security for your PC. Make sure that this feature is turned on.</li>
<li>In addition to an antivirus, it is worthwhile to spend a few bucks on a good anti-spyware program. This can provide extra security for your computer.</li>
<li>Never open any email attachments that come from untrusted sources. If it is a picture, text or sound file (these attachments end in the extensions .txt, .jpeg, .gif, .bmp, .tif, .mp3, .htm, .html, and .avi), you are probably safe, but still perform a virus scan before opening them.</li>
<li>Do not use disks that other people gave you, even from work. The disk could be infected with a virus. Of course, you can run a virus scan on it first to check it out.</li>
<li>Set up your <a class="zem_slink" title="Windows Update" href="http://en.wikipedia.org/wiki/Windows_Update" rel="wikipedia" target="_blank">Windows update</a> to automatically download patches and upgrades. This will allow your computer to automatically download any updates to both the operating system and <a class="zem_slink" title="Internet Explorer" href="http://web-browsers.findthebest.com/l/4/Internet-Explorer" rel="fdbsoftware" target="_blank">Internet Explorer</a>. These updates fix security holes in both pieces of software.</li>
<li>While you download files from untrusted websites/sources such as torrents, warez etc. make sure that you run a virus scan before executing them.</li>
<li>And finally it is recommended not to visit those websites that feature illegal/unwanted stuffs such as cracks, serials, warez etc. as they contribute much in spreading of virus and other malicious programs.</li>
</ol>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Enhanced by Zemanta" href="http://www.zemanta.com/?px"><img class="zemanta-pixie-img" style="border: none; float: right;" src="http://i2.wp.com/img.zemanta.com/zemified_e.png" alt="Enhanced by Zemanta" data-recalc-dims="1" /></a></div>
</div>]]></content:encoded>
			<wfw:commentRss>http://latest-tutorial.com/2013/02/26/12-tips-to-maintain-a-virus-free-computer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Find Out Your Visitor’s Position Using HTML5 Geolocation</title>
		<link>http://latest-tutorial.com/2012/03/15/find-out-your-visitors-position-using-html5-geolocation/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=find-out-your-visitors-position-using-html5-geolocation</link>
		<comments>http://latest-tutorial.com/2012/03/15/find-out-your-visitors-position-using-html5-geolocation/#comments</comments>
		<pubDate>Thu, 15 Mar 2012 07:33:40 +0000</pubDate>
		<dc:creator>Zeeshan Akhter</dc:creator>
				<category><![CDATA[Android Tutorials]]></category>
		<category><![CDATA[Aspx.NET Tutorials]]></category>
		<category><![CDATA[Courses]]></category>
		<category><![CDATA[Java Posts]]></category>
		<category><![CDATA[JavaScript Tutorials]]></category>
		<category><![CDATA[Random Posts]]></category>
		<category><![CDATA[beginner java tutorial]]></category>
		<category><![CDATA[Exception handling]]></category>
		<category><![CDATA[free java tutorials]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[google maps]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[java beginner]]></category>
		<category><![CDATA[java development.]]></category>
		<category><![CDATA[java online tutorial]]></category>
		<category><![CDATA[java programming]]></category>
		<category><![CDATA[java source code]]></category>
		<category><![CDATA[java tutorial]]></category>
		<category><![CDATA[java tutorial video]]></category>
		<category><![CDATA[latitude]]></category>
		<category><![CDATA[learn java]]></category>
		<category><![CDATA[online java tutorial]]></category>
		<category><![CDATA[programmer]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[usage share of web browsers]]></category>
		<category><![CDATA[web browser]]></category>

		<guid isPermaLink="false">http://shanisk.wordpress.com/?p=905</guid>
		<description><![CDATA[Geolocation is a way for the user to retrieve their position and share where they are. This can be done in a few ways, by using a GPS as the one in your new smartphone or connected to your computer is the most precise method. But for users without GPS the browser will use your [...]]]></description>
				<content:encoded><![CDATA[<div class="page-restrict-output"><p>Geolocation is a way for the user to retrieve their position and share where they are. This can be done in a few ways, by using a GPS as the one in your new smartphone or connected to your computer is the most precise method. But for users without GPS the browser will use your IP and or try to find nearby WLAN stations, however this is not as precise but gives some idea of where they are. Exactly how this is done is not a W3C standard and each browser have their own way to do it.</p>
<p>Even though geolocation is really complicated it’s quite easy for you to implement. In this tutorial I will show you how to retrieve the user’s position and display it on a map using Google Maps. So lets get started.</p>
<h2></h2>
<p>[wp_cart:Find Out Your Visitor’s Position Using HTML5 Geolocation:price:6:end]<br />
<?php echo print_wp_cart_button_for_product(’Find Out Your Visitor’s Position Using HTML5 Geolocation’, 6); ?><br />
Step 1. Create the HTML layout</p>
<p>We start of by creating a simple HTML page containing three div tags. One for the current status, one to display the data retrieved and one for displaying the user’s position on a map.</p>
<div>
<div id="highlighter_18125">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
<div>8</div>
<div>9</div>
<div>10</div>
<div>11</div>
<div>12</div>
</td>
<td>
<div>
<div><code>&lt;!DOCTYPE html&gt;</code></div>
<div><code>&lt;</code><code>html</code><code>&gt;</code></div>
<div><code>  </code><code>&lt;</code><code>head</code><code>&gt;</code></div>
<div><code>    </code><code>&lt;</code><code>title</code><code>&gt;HTML5 Geolocation&lt;/</code><code>title</code><code>&gt;</code></div>
<div><code>    </code><code>&lt;</code><code>script</code> <code>src</code><code>=</code><code>"<a href="http://maps.googleapis.com/maps/api/js?sensor=false">http://maps.googleapis.com/maps/api/js?sensor=false</a>"</code><code>&gt;&lt;/</code><code>script</code><code>&gt;</code></div>
<div><code>  </code><code>&lt;/</code><code>head</code><code>&gt;</code></div>
<div><code>  </code><code>&lt;</code><code>body</code> <code>onload</code><code>=</code><code>"initialize()"</code><code>&gt;</code></div>
<div><code>    </code><code>&lt;</code><code>div</code> <code>id</code><code>=</code><code>"status"</code><code>&gt;&lt;/</code><code>div</code><code>&gt;</code></div>
<div><code>    </code><code>&lt;</code><code>div</code> <code>id</code><code>=</code><code>"data"</code><code>&gt;&lt;/</code><code>div</code><code>&gt;</code></div>
<div><code>    </code><code>&lt;</code><code>div</code> <code>id</code><code>=</code><code>"map_canvas"</code> <code>style</code><code>=</code><code>"width: 640px; height: 480px"</code><code>&gt;&lt;/</code><code>div</code><code>&gt;</code></div>
<div><code>  </code><code>&lt;/</code><code>body</code><code>&gt;</code></div>
<div><code>&lt;/</code><code>html</code><code>&gt;</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>We also include the Google Maps API, it’s important to set sensors=false in the URL, otherwise Google will try to find out the user’s position for us.</p>
<p>The initialize function we’re calling on load will try to fetch the position for us.</p>
<h2>Step 2. Retrieve the Position</h2>
<p>Next it’s time to create our initialize function which will call the geolocation API to get the position data.</p>
<div>
<div id="highlighter_125080">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
<div>8</div>
<div>9</div>
<div>10</div>
<div>11</div>
<div>12</div>
<div>13</div>
<div>14</div>
<div>15</div>
<div>16</div>
<div>17</div>
</td>
<td>
<div>
<div><code>// Initialize geolocation</code></div>
<div><code>function</code> <code>initialize() {</code></div>
<div><code>  </code><code>if</code> <code>(navigator.geolocation) {</code></div>
<div><code>    </code><code>document.getElementById(</code><code>'status'</code><code>).innerHTML = </code><code>'Checking...'</code><code>;</code></div>
<div></div>
<div><code>    </code><code>navigator.geolocation.getCurrentPosition(</code></div>
<div><code>      </code><code>onSuccess,</code></div>
<div><code>      </code><code>onError, {</code></div>
<div><code>        </code><code>enableHighAccuracy: </code><code>true</code><code>,</code></div>
<div><code>        </code><code>timeout: 20000,</code></div>
<div><code>        </code><code>maximumAge: 120000</code></div>
<div><code>      </code><code>});</code></div>
<div><code>  </code><code>}</code></div>
<div><code>  </code><code>else</code> <code>{</code></div>
<div><code>    </code><code>document.getElementById(</code><code>'status'</code><code>).innerHTML = </code><code>'Geolocation not supported.'</code><code>;</code></div>
<div><code>  </code><code>}</code></div>
<div><code>}</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>First we check if the browser actually supports geolocation. Browser who supports geolocation are Internet Explorer 9, Firefox 3.5+, Chrome 5+, Opera 10.6+ and Safari 5+. So it’s quite widely supported already, but if the user has an old browser we show them a message telling them that geolocation is not supported.</p>
<p>Next we set the status message to “Checking…” to tell the user that we’re trying to fetch the location data since this might take some time. Then we call navigator.geolocation.getCurrentPosition which will try to retrieve the user’s position, it calls the onSuccess function if it succeeds, otherwise it will call the onError. These functions will be created in the next two steps.</p>
<p>There’s also a few optional parameters to the getCurrentPosition function. These are enableHighAccuracy which tells the web browser to try using the clients GPS if possible, the default value for this is false. The timeout parameter tells the browser how long we’re ready to wait to get the position in milliseconds, the default value is infinite. Lastly we have the maximumAge parameter which tells the browser how old the position cache is allowed to be in milliseconds, the default value for maximumAge is 0 which turns off cache completely.</p>
<p>Since geolocation is a big privacy concern the W3C standards requires the user to agree to share their position before the location is sent to the website, so when we call the getCurrentPosition a information bar will be shown to the user where the user has to allow us to get the position, if the user denies the onError will be function will be called.</p>
<div>
<h3>Tip</h3>
<p>Don’t rely fully on getting the user’s location since the user might deny your site from retrieving the position or something might go wrong. Always have a fallback solution if retrieving the position is critical.</p>
</div>
<h2>Step 3. On Success</h2>
<p>Next we add an onSuccess function to our script section. This function will display the data received and call the loadMap function to load our map.</p>
<div>
<div id="highlighter_779379">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
<div>8</div>
<div>9</div>
<div>10</div>
<div>11</div>
<div>12</div>
<div>13</div>
<div>14</div>
<div>15</div>
<div>16</div>
</td>
<td>
<div>
<div><code>// Map position retrieved successfully</code></div>
<div><code>function</code> <code>onSuccess(position) {</code></div>
<div><code>  </code><code>var</code> <code>data = </code><code>''</code><code>;</code></div>
<div></div>
<div><code>  </code><code>data += </code><code>'latitude: '</code> <code>+ position.coords.latitude + </code><code>'&lt;br/&gt;'</code><code>;</code></div>
<div><code>  </code><code>data += </code><code>'longitude: '</code> <code>+ position.coords.longitude + </code><code>'&lt;br/&gt;'</code><code>;</code></div>
<div><code>  </code><code>data += </code><code>'altitude: '</code> <code>+ position.coords.altitude + </code><code>'&lt;br/&gt;'</code><code>;</code></div>
<div><code>  </code><code>data += </code><code>'accuracy: '</code> <code>+ position.coords.accuracy + </code><code>'&lt;br/&gt;'</code><code>;</code></div>
<div><code>  </code><code>data += </code><code>'altitudeAccuracy: '</code> <code>+ position.coords.altitudeAccuracy + </code><code>'&lt;br/&gt;'</code><code>;</code></div>
<div><code>  </code><code>data += </code><code>'heading: '</code> <code>+ position.coords.heading + </code><code>'&lt;br/&gt;'</code><code>;</code></div>
<div><code>  </code><code>data += </code><code>'speed: '</code> <code>+ position.coords.speed + </code><code>'&lt;br/&gt;'</code><code>;</code></div>
<div></div>
<div><code>  </code><code>document.getElementById(</code><code>'data'</code><code>).innerHTML = data;</code></div>
<div></div>
<div><code>  </code><code>loadMap(position.coords.latitude, position.coords.longitude);</code></div>
<div><code>}</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>This function is quite self explanatory, we build a string with the retrieved data found in the position variable and shows it to our user. You will always get the latitude, longitude and accuracy values but the rest is optional and will probably only be set if the user has a GPS which the data is retrieved from.</p>
<p>Lastly we call the loadMap function and give the latitude and longitude to show where the user is on a map.</p>
<h2>Step 4. On Error</h2>
<p>Since geolocation is quite complex a lot can go wrong and we need an error handler. There’s four different error codes, 0 is an unknown error, 1 occurs if you deny the browser from retrieving your location, 2 occurs if the browse somehow fails to retrieve the location and 3 if our timeout variable is too short and the timeout expired.</p>
<div>
<div id="highlighter_19730">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
<div>8</div>
<div>9</div>
<div>10</div>
<div>11</div>
<div>12</div>
<div>13</div>
<div>14</div>
<div>15</div>
<div>16</div>
<div>17</div>
<div>18</div>
<div>19</div>
<div>20</div>
<div>21</div>
</td>
<td>
<div>
<div><code>// Error handler</code></div>
<div><code>function</code> <code>onError(err) {</code></div>
<div><code>  </code><code>var</code> <code>message;</code></div>
<div></div>
<div><code>  </code><code>switch</code> <code>(err.code) {</code></div>
<div><code>    </code><code>case</code> <code>0:</code></div>
<div><code>      </code><code>message = </code><code>'Unknown error: '</code> <code>+ err.message;</code></div>
<div><code>      </code><code>break</code><code>;</code></div>
<div><code>    </code><code>case</code> <code>1:</code></div>
<div><code>      </code><code>message = </code><code>'You denied permission to retrieve a position.'</code><code>;</code></div>
<div><code>      </code><code>break</code><code>;</code></div>
<div><code>    </code><code>case</code> <code>2:</code></div>
<div><code>      </code><code>message = </code><code>'The browser was unable to determine a position: '</code> <code>+ error.message;</code></div>
<div><code>      </code><code>break</code><code>;</code></div>
<div><code>    </code><code>case</code> <code>3:</code></div>
<div><code>      </code><code>message = </code><code>'The browser timed out before retrieving the position.'</code><code>;</code></div>
<div><code>      </code><code>break</code><code>;</code></div>
<div><code>  </code><code>}</code></div>
<div></div>
<div><code>  </code><code>document.getElementById(</code><code>'status'</code><code>).innerHTML = message;</code></div>
<div><code>}</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>This function is also quite easy to understand, we get the error as a parameter to our function and shows the user a message depending on the error code retrieved.</p>
<h3>Step 5. Display the Map</h3>
<p>Next we display a map in our map_canvas div. This has really nothing to do with the HTML5 geolocation. So I won’t explain this for you, but it shouldn’t be too hard to understand.</p>
<div>
<h3>Tip</h3>
<p>If you want to learn more about Google maps check out their API <a href="http://code.google.com/apis/maps/documentation/javascript/" target="_blank">here</a>.</p>
</div>
<div>
<div id="highlighter_136316">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
<div>8</div>
<div>9</div>
<div>10</div>
<div>11</div>
<div>12</div>
<div>13</div>
<div>14</div>
<div>15</div>
<div>16</div>
<div>17</div>
<div>18</div>
<div>19</div>
<div>20</div>
</td>
<td>
<div>
<div><code>// Integration with google maps</code></div>
<div><code>function</code> <code>loadMap(lat, lng) {</code></div>
<div><code>  </code><code>var</code> <code>latlng = </code><code>new</code> <code>google.maps.LatLng(lat, lng);</code></div>
<div></div>
<div><code>  </code><code>var</code> <code>settings = {</code></div>
<div><code>    </code><code>zoom: 14,</code></div>
<div><code>    </code><code>center: latlng,</code></div>
<div><code>    </code><code>mapTypeId: google.maps.MapTypeId.ROADMAP</code></div>
<div><code>  </code><code>};</code></div>
<div></div>
<div><code>  </code><code>var</code> <code>map = </code><code>new</code> <code>google.maps.Map(document.getElementById(</code><code>'map_canvas'</code><code>), settings);</code></div>
<div></div>
<div><code>  </code><code>var</code> <code>marker = </code><code>new</code> <code>google.maps.Marker({</code></div>
<div><code>    </code><code>position: latlng,</code></div>
<div><code>    </code><code>map: map,</code></div>
<div><code>    </code><code>title: </code><code>'Your Position!'</code></div>
<div><code>  </code><code>});  </code></div>
<div></div>
<div><code>  </code><code>document.getElementById(</code><code>'status'</code><code>).innerHTML = </code><code>'Position Found!'</code><code>;</code></div>
<div><code>}</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>That’s all for today. You can try out or download the finished code below.</p>
<div>
<h3>Example</h3>
<p>Try out the finished example here: <a href="http://www.worldwidewhat.net/extras/html5-geolocation/index.htm" target="_blank">Example</a>.</p>
</div>
<div>
<h3>Download</h3>
<p>Download the source from here: <a href="http://www.worldwidewhat.net/extras/html5-geolocation/html5-geolocation.zip">Download</a></p>
</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://latest-tutorial.com/2012/03/15/find-out-your-visitors-position-using-html5-geolocation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
