<?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>CAM Web Design &#187; jQuery</title>
	<atom:link href="http://camwebdesign.com/category/techniques/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://camwebdesign.com</link>
	<description>High quality, cost effective wed design and hosting solutions</description>
	<lastBuildDate>Mon, 12 Dec 2011 11:48:26 +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>Detect iPad with javascript</title>
		<link>http://camwebdesign.com/techniques/detect-ipad-with-javascript/</link>
		<comments>http://camwebdesign.com/techniques/detect-ipad-with-javascript/#comments</comments>
		<pubDate>Mon, 08 Aug 2011 06:50:34 +0000</pubDate>
		<dc:creator>Corey</dc:creator>
				<category><![CDATA[iPad]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Techniques]]></category>

		<guid isPermaLink="false">http://camwebdesign.com/?p=1799</guid>
		<description><![CDATA[We created and maintain an intranet website for an electric utility (of whom I work for &#8211; they pay my bills).  The site is accessed by personnel with iPads, and it contains some flash content (AccuWeather Accunet and Open Flash Chart). As you may already know flash is not supported by Apple&#8217;s Safari browser. We <a href="http://camwebdesign.com/techniques/detect-ipad-with-javascript/" class="more-link">(more...)</a>]]></description>
			<content:encoded><![CDATA[<p>We created and maintain an <a href="/portfolio/ace-system-operations/">intranet website for an electric utility</a> (of whom I work for &#8211; they pay my bills).  The site is accessed by personnel with iPads, and it contains some flash content (<a href="http://www.accuweather.com/accunet/index.asp">AccuWeather Accunet</a> and <a href="http://teethgrinder.co.uk/open-flash-chart-2/">Open Flash Chart</a>).  As you may already know flash is not <span id="more-1799"></span>supported by Apple&#8217;s Safari browser.  We wanted to detect if the user was accessing the site with an iPad.  If they are we use <a href="http://jquery.com/">jQuery</a> to alter the HTML code, removing the flash content and display a message &#8220;Some content not available, your device does not support Flash&#8221;.  Of course we could replace the HTML with alternative content rather than the pat message, but for our needs this is what we&#8217;ve done.</p>
<p>First we use one line of javascript to detect if the user agent is an iPad.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">var isiPad <span style="color: #339933;">=</span> navigator.<span style="color: #006633;">userAgent</span>.<span style="color: #006633;">match</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">/</span>iPad<span style="color: #339933;">/</span>i<span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Then we use jQuery to replace the HTML, where necessary, with our message using the <a href="http://api.jquery.com/html"><code>html()</code></a> function.  Exampled below, we&#8217;re replacing the HTML if a <code>&lt;div&gt;</code> with an id of AccuWeather, with our message.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>isiPad <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  $<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;#AccuWeather&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">html</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Some content not available, your device does not support Flash'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Our stance on Adobe Flash, we fully support the new HTML5 and CSS3 standards, and are not fans of Flash.  Nor are we fans of Adobe&#8217;s new product <a href="http://labs.adobe.com/technologies/edge/">Edge</a>.  We prefer to hand code, it&#8217;s usually much lighter and more understandable than code from a WYSIWYG.<strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://camwebdesign.com/techniques/using-html5-with-your-thematic-child-theme/" rel="bookmark" title="August 14, 2010">Using HTML5 with your Thematic Child Theme</a></li>
<li><a href="http://camwebdesign.com/techniques/wordpress-3-0-menu-management/" rel="bookmark" title="July 9, 2010">WordPress 3.0 Menu Management</a></li>
<li><a href="http://camwebdesign.com/techniques/wordpress-create-custom-roles-and-capabilities/" rel="bookmark" title="June 11, 2010">WordPress Create Custom Roles and Capabilities</a></li>
</ul>
<p><!-- Similar Posts took 16.384 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://camwebdesign.com/techniques/detect-ipad-with-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

