<?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>HTML element &#8211; stoimen&#039;s web log</title>
	<atom:link href="/tag/html-element/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>on web development</description>
	<lastBuildDate>Tue, 13 Feb 2018 08:18:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.0.3</generator>
	<item>
		<title>How to Collect the Images and Meta Tags from a Webpage with PHP</title>
		<link>/2011/02/25/how-to-collect-the-images-and-meta-tags-from-a-webpage-with-php/</link>
		<comments>/2011/02/25/how-to-collect-the-images-and-meta-tags-from-a-webpage-with-php/#comments</comments>
		<pubDate>Fri, 25 Feb 2011 09:23:50 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Facebook Inc]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[HTML element]]></category>
		<category><![CDATA[LinkedIn Corporation]]></category>
		<category><![CDATA[Meta element]]></category>
		<category><![CDATA[Meta Tags]]></category>
		<category><![CDATA[Online social networking]]></category>
		<category><![CDATA[Search engine optimization]]></category>
		<category><![CDATA[search engines]]></category>
		<category><![CDATA[social services]]></category>
		<category><![CDATA[tag]]></category>
		<category><![CDATA[Technical communication]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[Web page]]></category>
		<category><![CDATA[World Wide Web]]></category>

		<guid isPermaLink="false">/?p=2216</guid>
		<description><![CDATA[Meta Tags and the Facebook Example You&#8217;ve definitely seen the &#8220;share a link&#8221; screen in Facebook. When you paste a link into the box (fig. 1) and press the &#8220;Attach&#8221; button you&#8217;ll get the prompted cite parsed with a title, description and possibly thumb (fig. 2). This functionality is well known in Facebook, but it &#8230; <a href="/2011/02/25/how-to-collect-the-images-and-meta-tags-from-a-webpage-with-php/" class="more-link">Continue reading <span class="screen-reader-text">How to Collect the Images and Meta Tags from a Webpage with PHP</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/04/20/how-to-sanitize-user-input-in-php/" rel="bookmark" title="How to Sanitize User Input in PHP?">How to Sanitize User Input in PHP? </a></li>
<li><a href="/2010/08/03/html-tags/" rel="bookmark" title="HTML Tags: &lt;base&gt;">HTML Tags: &lt;base&gt; </a></li>
<li><a href="/2010/09/10/automatically-upload-images-with-php-directly-from-the-uri/" rel="bookmark" title="Automatically Upload Images with PHP Directly from the URI">Automatically Upload Images with PHP Directly from the URI </a></li>
<li><a href="/2011/01/18/download-images-with-php/" rel="bookmark" title="Download Images with PHP">Download Images with PHP </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>Meta Tags and the Facebook Example</h2>
<p>You&#8217;ve definitely seen the &#8220;share a link&#8221; screen in <a title="Facebook Homepage" href="http://www.facebook.com/" target="_blank">Facebook</a>. When you paste a link into the box (fig. 1) and press the &#8220;Attach&#8221; button you&#8217;ll get the prompted cite parsed with a title, description and possibly thumb (fig. 2). This functionality is well known in Facebook, but it appears to be well known also in various social services. In fact <a title="LinkedIn Homepage" href="http://www.linkedin.com/" target="_blank">Linkedin</a>, <a title="Reddit Homepage" href="http://www.reddit.com/" target="_blank">Reddit</a>, <a title="DZone Homepage" href="http://www.dzone.com/" target="_blank">Dzone</a>&#8216;s <a title="DZone Bookmarklet" href="http://www.dzone.com/links/add.html" target="_blank">bookmarklet</a> use it.</p>
<figure id="attachment_2222" style="width: 518px" class="wp-caption aligncenter"><a href="/wp-content/uploads/2011/02/facebook_attach_prompt_screen.png"><img class="size-full wp-image-2222" title="facebook_attach_prompt_screen" src="/wp-content/uploads/2011/02/facebook_attach_prompt_screen.png" alt="Facebook Attach a Link Prompt Screen" width="518" height="155" srcset="/wp-content/uploads/2011/02/facebook_attach_prompt_screen.png 518w, /wp-content/uploads/2011/02/facebook_attach_prompt_screen-300x89.png 300w" sizes="(max-width: 518px) 100vw, 518px" /></a><figcaption class="wp-caption-text">fig. 1 - Facebook Attach a Link Prompt Screen</figcaption></figure>
<p>Fist thing to notice is that this information, prompted by Facebook, is the same as the meta tag information. However there is a slight difference.</p>
<figure id="attachment_2224" style="width: 526px" class="wp-caption aligncenter"><a href="/wp-content/uploads/2011/02/facebook_attached_link_screen.png"><img class="size-full wp-image-2224" title="facebook_attached_link_screen" src="/wp-content/uploads/2011/02/facebook_attached_link_screen.png" alt="Facebook Attached Link Screen" width="526" height="362" srcset="/wp-content/uploads/2011/02/facebook_attached_link_screen.png 526w, /wp-content/uploads/2011/02/facebook_attached_link_screen-300x206.png 300w" sizes="(max-width: 526px) 100vw, 526px" /></a><figcaption class="wp-caption-text">fig. 2 - Facebook Attached Link Screen</figcaption></figure>
<p>Facebook prefers for the thumb the image set into the &lt;meta property=&#8221;og:image&#8221; &#8230; /&gt;. In the case above this tag appears to be:</p>
<pre lang="html4strict" escaped="true">
<meta property="og:image" content="http://b.vimeocdn.com/ts/572/975/57297584_200.jpg" />
</pre>
<p>And the image pointed in the SRC attribute is exactly the same as the one prompted by Facebook (fig. 3).</p>
<figure id="attachment_2229" style="width: 200px" class="wp-caption aligncenter"><a href="/wp-content/uploads/2011/02/vimeo_thumb.jpg"><img class="size-full wp-image-2229" title="vimeo_thumb" src="/wp-content/uploads/2011/02/vimeo_thumb.jpg" alt="Vimeo Thumb" width="200" height="150" /></a><figcaption class="wp-caption-text">fig. 3 - Vimeo Thumb</figcaption></figure>
<p>First thing to note is that the real thumb is bigger than the thumb shown in Facebook, so Facebook resizes it and the second thing to note is that there are more meta tags of the og:&#8230; format.<span id="more-2216"></span></p>
<h2>Meta Tags and The Open Graph Protocol</h2>
<p>By default meta tags contain various information about the web page. They are not visible in the webpage, but contain some info about it. The most common meta tags are the title, description and keywords tags. They of course contain the title of the page, not that this can be different from the &lt;title&gt; tag, a short description of the page and some keywords describing the content of the page. They are well known also because the search engines make use of them when trying to collect information about the page and the process of SEO passes through it.</p>
<p>However the <a title="Default HTML Meta Tags Specification" href="http://www.w3schools.com/tags/tag_meta.asp" target="_blank">default HTML meta tags</a> cannot contain everything. Thus for example you cannot point the preferable thumbnail for a webpage. The solution is the <a title="The Open Graph Protocol Homepage" href="http://ogp.me/" target="_blank">Open Graph Protocol</a>. It comes with meta tags that can contain more and more valuable info. Such a tag is the og:image meta tag. Note that all the Open Graph (og) meta tags are defined by the og: prefix before the entity name. Thus og:image comes for images, while og:longitude for geo positioning.</p>
<p>That&#8217;s really useful, but how you can read them?</p>
<h2>PHP, Meta Tags and Regexps</h2>
<p>When you try to read information from a webpage source the first possible path is by using <a title="Regular Expressions Explained on Wikipedia" href="http://en.wikipedia.org/wiki/Regular_expression" target="_blank">regular expressions</a>. However PHP is smart enough to offer you some useful functions. Such a function is <a title="PHP get_meta_tags Function Documentation" href="http://php.net/manual/en/function.get-meta-tags.php" target="_blank">get_meta_tags()</a>. As you may guess this method reads the meta tags by given URL.</p>
<pre lang="php" escaped="true">
$a = get_meta_tags('http://vimeo.com/10758212');
var_dump($a);
</pre>
<p>However this method can&#8217;t read Open Graph tags. So finally you&#8217;ve to use some regexps.</p>
<pre lang="php" escaped="true">
preg_match('/<meta property="og:image" content="(.*?)" \/>/', $source, $matches);
</pre>
<p>Now you can grab the og:image tag. And even more &#8211; grab every image (&lt;img&gt;) from that page.</p>
<pre lang="php" escaped="true">
preg_match_all('/<img src="(.*?)"/', $source, $m);
</pre>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/04/20/how-to-sanitize-user-input-in-php/" rel="bookmark" title="How to Sanitize User Input in PHP?">How to Sanitize User Input in PHP? </a></li>
<li><a href="/2010/08/03/html-tags/" rel="bookmark" title="HTML Tags: &lt;base&gt;">HTML Tags: &lt;base&gt; </a></li>
<li><a href="/2010/09/10/automatically-upload-images-with-php-directly-from-the-uri/" rel="bookmark" title="Automatically Upload Images with PHP Directly from the URI">Automatically Upload Images with PHP Directly from the URI </a></li>
<li><a href="/2011/01/18/download-images-with-php/" rel="bookmark" title="Download Images with PHP">Download Images with PHP </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2011/02/25/how-to-collect-the-images-and-meta-tags-from-a-webpage-with-php/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>HTML Tags: &#060;base&#062;</title>
		<link>/2010/08/03/html-tags/</link>
		<comments>/2010/08/03/html-tags/#comments</comments>
		<pubDate>Tue, 03 Aug 2010 12:38:03 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[Comparison of layout engines]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Conditional comment]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[HTML element]]></category>
		<category><![CDATA[Hyperlink]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[World Wide Web]]></category>

		<guid isPermaLink="false">/?p=1874</guid>
		<description><![CDATA[Overview Somehow the &#60;base&#62; tag remains unknown to most of the web developers, but that&#8217;s quite normal. However let see what it can do. By adding the &#60;base&#62; tag in the head of the page you tell every link into that page how to open and a default href value. Thus if you have: every &#8230; <a href="/2010/08/03/html-tags/" class="more-link">Continue reading <span class="screen-reader-text">HTML Tags: &#60;base&#62;</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2011/02/25/how-to-collect-the-images-and-meta-tags-from-a-webpage-with-php/" rel="bookmark" title="How to Collect the Images and Meta Tags from a Webpage with PHP">How to Collect the Images and Meta Tags from a Webpage with PHP </a></li>
<li><a href="/2009/02/22/html-object-and-embed-tags/" rel="bookmark" title="Html object &#038; embed tags">Html object &#038; embed tags </a></li>
<li><a href="/2010/03/10/change-the-viewport-be-ready-for-the-iphone/" rel="bookmark" title="Change the Viewport, be Ready for the iPhone!">Change the Viewport, be Ready for the iPhone! </a></li>
<li><a href="/2010/03/11/html-tag-semantics-strong-vs-b/" rel="bookmark" title="HTML Tag Semantics. STRONG vs. B!">HTML Tag Semantics. STRONG vs. B! </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>Overview</h2>
<p><a href="/wp-content/uploads/2010/08/base.jpg"><img class="aligncenter size-full wp-image-1882" title="base" src="/wp-content/uploads/2010/08/base.jpg" alt="base" width="430" height="142" srcset="/wp-content/uploads/2010/08/base.jpg 430w, /wp-content/uploads/2010/08/base-300x99.jpg 300w" sizes="(max-width: 430px) 100vw, 430px" /></a></p>
<p>Somehow the &lt;base&gt; tag remains unknown to most of the web developers, but that&#8217;s quite normal. However let see what it can do. By adding the &lt;base&gt; tag in the head of the page you tell every link into that page how to open and a default href value. Thus if you have:</p>
<pre lang="html4strict">
<base href="/">
</pre>
<p>every link without a href attribute will open this link. That&#8217;s really useful in some cases. However the most interesting part of the base tag is the target attribute.</p>
<h2>target=&#8221;_blank&#8221;</h2>
<p>Everybody knows what will result from this attribute attached to a anchor tag.</p>
<pre lang="html4strict">
<a href="http://www.stoimen.com/" target="_blank">Click Here</a>
</pre>
<p>But with only adding this base tag:</p>
<pre lang="html4strict">
<base target="_blank">
</pre>
<p>into the head &#8230; all the links will open in a new tab/window, depending on the browser preferences.</p>
<h2>Watch out!</h2>
<p>If you add the line above somewhere into the &lt;body&gt; tag the browser, will put it into the &lt;head&gt; which will make it difficult to track. A good practice is to place it directly into the &lt;head&gt;!</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2011/02/25/how-to-collect-the-images-and-meta-tags-from-a-webpage-with-php/" rel="bookmark" title="How to Collect the Images and Meta Tags from a Webpage with PHP">How to Collect the Images and Meta Tags from a Webpage with PHP </a></li>
<li><a href="/2009/02/22/html-object-and-embed-tags/" rel="bookmark" title="Html object &#038; embed tags">Html object &#038; embed tags </a></li>
<li><a href="/2010/03/10/change-the-viewport-be-ready-for-the-iphone/" rel="bookmark" title="Change the Viewport, be Ready for the iPhone!">Change the Viewport, be Ready for the iPhone! </a></li>
<li><a href="/2010/03/11/html-tag-semantics-strong-vs-b/" rel="bookmark" title="HTML Tag Semantics. STRONG vs. B!">HTML Tag Semantics. STRONG vs. B! </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/08/03/html-tags/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Bind Zend Action with Non-Default View &#8211; Part 2</title>
		<link>/2010/06/23/bind-zend-action-with-non-default-view-part-2/</link>
		<comments>/2010/06/23/bind-zend-action-with-non-default-view-part-2/#comments</comments>
		<pubDate>Wed, 23 Jun 2010 14:26:41 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[zend framework]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[HTML element]]></category>
		<category><![CDATA[PHP programming language]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[Web application frameworks]]></category>
		<category><![CDATA[World Wide Web]]></category>
		<category><![CDATA[zend]]></category>
		<category><![CDATA[zend view renderer]]></category>

		<guid isPermaLink="false">/?p=1664</guid>
		<description><![CDATA[Typical Setup Typically Zend Framework is setup to bind every controller&#8217;s action to a specific view. The names of the action and the view script must be the same, or at least must be similar &#8211; following the ZF&#8217;s convention. Thus if you name an action, let&#8217;s say, indexAction(), you&#8217;ve to create an index.phtml file &#8230; <a href="/2010/06/23/bind-zend-action-with-non-default-view-part-2/" class="more-link">Continue reading <span class="screen-reader-text">Bind Zend Action with Non-Default View &#8211; Part 2</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/06/07/bind-zend-action-with-non-default-view/" rel="bookmark" title="Bind Zend Action with Non-Default View">Bind Zend Action with Non-Default View </a></li>
<li><a href="/2010/06/24/zend-framework-inject-javascript-code-in-a-actionview/" rel="bookmark" title="Zend Framework: Inject JavaScript Code in a Action/View">Zend Framework: Inject JavaScript Code in a Action/View </a></li>
<li><a href="/2010/01/29/escaping-strings-in-a-zend-framework-view-prevent-unclosed-tags/" rel="bookmark" title="Escaping strings in a Zend Framework view. Prevent unclosed tags!">Escaping strings in a Zend Framework view. Prevent unclosed tags! </a></li>
<li><a href="/2010/04/27/inline-scripts-with-zend_view_helper_inlinescript/" rel="bookmark" title="Inline Scripts with Zend_View_Helper_InlineScript">Inline Scripts with Zend_View_Helper_InlineScript </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>Typical Setup</h2>
<p>Typically <a href="http://framework.zend.com/">Zend Framework</a> is setup to bind every controller&#8217;s action to a specific view. The names of the action and the view script must be the same, or at least must be similar &#8211; following the ZF&#8217;s convention.</p>
<p>Thus if you name an action, let&#8217;s say, indexAction(), you&#8217;ve to create an index.phtml file into the views/scripts/index/ folder. Let me remind you that this is what is called a typical setup, but this may vary from one installation to another.</p>
<p>Thus everything&#8217;s fine and the MVC does its best. After the user requests a specific uri, the framework parses it and finds the controller, than the action and than the view script &#8211; and there is a view script for every single action.</p>
<p><a href="/wp-content/uploads/2010/06/typical-zend-framework-setup.jpg"><img class="alignleft size-medium wp-image-1675" title="typical-zend-framework-setup" src="/wp-content/uploads/2010/06/typical-zend-framework-setup-300x162.jpg" alt="typical zend framework setup" width="300" height="162" srcset="/wp-content/uploads/2010/06/typical-zend-framework-setup-300x162.jpg 300w, /wp-content/uploads/2010/06/typical-zend-framework-setup.jpg 545w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>When there are two or more actions &#8211; there are two or more .phtml (view scripts) files.</p>
<p><a href="/wp-content/uploads/2010/06/typical-zend-framework-setup2.jpg"><img class="alignleft size-medium wp-image-1676" title="typical-zend-framework-setup2" src="/wp-content/uploads/2010/06/typical-zend-framework-setup2-300x203.jpg" alt="typical zend framework setup for two or more actions" width="300" height="203" srcset="/wp-content/uploads/2010/06/typical-zend-framework-setup2-300x203.jpg 300w, /wp-content/uploads/2010/06/typical-zend-framework-setup2.jpg 630w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<h2>Some Exceptions</h2>
<p>Sometimes you have very similar logic, but very different markup between two actions. As the logic goes to the controller/action and the markup into the view, the question is can you simply have one action in the controller, but with two different .phtml file as a view scripts?  Of course switching between those two (or more) with some conditionals.</p>
<h3>Solution No. 1</h3>
<p>However once I posted a simple, and working, <a href="/2010/06/07/bind-zend-action-with-non-default-view/">solution</a>. There you have again two actions and two scripts:</p>
<pre lang="php">
<?php

class IndexController extends Zend_Controller_Action
{	
	public function firstAction()
	{
		// place all the logic you need here
		// and every view placeholder assignment
		$this->view->title = "My Title";
		
		// if the logic requires a different markup
		// simply redirect to another view
		if (some_expression) {
			$this->_forward('second');	
		}	
	}
	
	public function secondAction()
	{}
}

// in the application/views/scripts/index
// 1. first.phtml
<h1><?php echo $this->title ?></h1>

// 2. second.phtml
<h2><?php echo $this->title ?></h2>
</pre>
<p>As you can see in the second action there&#8217;s no logic &#8211; it&#8217;s only serving the role of a bridge between the views. Everything is setup into the first action, but the second action is doing the relation with the second.phtml view script.</p>
<h3>Solution No. 2</h3>
<p>However there&#8217;s another solution with only one action and two scripts which makes something like that shown on the diagram bellow:</p>
<p><a href="/wp-content/uploads/2010/06/zend-framework-one-action-multiple-views.jpg"><img class="alignleft size-medium wp-image-1677" title="zend-framework-one-action-multiple-views" src="/wp-content/uploads/2010/06/zend-framework-one-action-multiple-views-300x203.jpg" alt="zend framework one action multiple=" height="203" srcset="/wp-content/uploads/2010/06/zend-framework-one-action-multiple-views-300x203.jpg 300w, /wp-content/uploads/2010/06/zend-framework-one-action-multiple-views.jpg 630w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>The only thing to do is to add some code to your action:</p>
<pre lang="php">
<?php

class IndexController extends Zend_Controller_Action
{	
	public function firstAction()
	{
		// place all the logic you need here
		// and every view placeholder assignment
		$this->view->title = "My Title";
		
		// if the logic requires a different markup
		// simply redirect to another view
		if (some_expression) {
			echo $this->view->render('index/second.phtml');
			$this->_helper->viewRenderer->setNoRender(true);
		}	
	}
}

// in the application/views/scripts/index
// 1. first.phtml
<h1><?php echo $this->title ?></h1>

// 2. second.phtml
<h2><?php echo $this->title ?></h2>
</pre>
<p>Note that you&#8217;ve to setNoRender on the view renderer once you render the other script!</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/06/07/bind-zend-action-with-non-default-view/" rel="bookmark" title="Bind Zend Action with Non-Default View">Bind Zend Action with Non-Default View </a></li>
<li><a href="/2010/06/24/zend-framework-inject-javascript-code-in-a-actionview/" rel="bookmark" title="Zend Framework: Inject JavaScript Code in a Action/View">Zend Framework: Inject JavaScript Code in a Action/View </a></li>
<li><a href="/2010/01/29/escaping-strings-in-a-zend-framework-view-prevent-unclosed-tags/" rel="bookmark" title="Escaping strings in a Zend Framework view. Prevent unclosed tags!">Escaping strings in a Zend Framework view. Prevent unclosed tags! </a></li>
<li><a href="/2010/04/27/inline-scripts-with-zend_view_helper_inlinescript/" rel="bookmark" title="Inline Scripts with Zend_View_Helper_InlineScript">Inline Scripts with Zend_View_Helper_InlineScript </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/06/23/bind-zend-action-with-non-default-view-part-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Change the Viewport, be Ready for the iPhone!</title>
		<link>/2010/03/10/change-the-viewport-be-ready-for-the-iphone/</link>
		<comments>/2010/03/10/change-the-viewport-be-ready-for-the-iphone/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 15:07:08 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[.mobi]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Digg]]></category>
		<category><![CDATA[Google Inc.]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[HTML element]]></category>
		<category><![CDATA[Human Interest]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[less decorated site]]></category>
		<category><![CDATA[Meta element]]></category>
		<category><![CDATA[Opera]]></category>
		<category><![CDATA[Opera Mini]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[World Wide Web]]></category>

		<guid isPermaLink="false">/?p=1247</guid>
		<description><![CDATA[Sites for mobile Have you ever noticed that once you start designing a site for mobile, as iPhone and Nexus One from Google are, the site is looking really ugly! These two devices in particular, as may other using Opera Mini for instance, scale the site, because only than you can view the entire layout &#8230; <a href="/2010/03/10/change-the-viewport-be-ready-for-the-iphone/" class="more-link">Continue reading <span class="screen-reader-text">Change the Viewport, be Ready for the iPhone!</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/03/17/stop-coding-iphone-apps-begin-with-html5-mobile-sites/" rel="bookmark" title="Stop Coding iPhone Apps, Begin with HTML5 Mobile Sites">Stop Coding iPhone Apps, Begin with HTML5 Mobile Sites </a></li>
<li><a href="/2010/03/22/php-mobile-devices-http_user_agent-strings/" rel="bookmark" title="PHP: Mobile Devices HTTP_USER_AGENT Strings">PHP: Mobile Devices HTTP_USER_AGENT Strings </a></li>
<li><a href="/2010/01/31/speed-up-the-javascript-it-can-change-dramatically-the-user-experience/" rel="bookmark" title="Speed up the JavaScript. It can change dramatically the user experience.">Speed up the JavaScript. It can change dramatically the user experience. </a></li>
<li><a href="/2010/08/03/html-tags/" rel="bookmark" title="HTML Tags: &lt;base&gt;">HTML Tags: &lt;base&gt; </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>Sites for mobile</h2>
<p>Have you ever noticed that once you start designing a site for mobile, as <a title="Apple iPhone" href="http://www.apple.com/iphone/" target="_blank">iPhone</a> and <a title="Nexus One from Google" href="http://www.google.com/phone/" target="_blank">Nexus One</a> from Google are, the site is looking really ugly! These two devices in particular, as may other using <a title="Opera Mini" href="http://www.opera.com/mini/" target="_blank">Opera Mini</a> for instance, scale the site, because only than you can view the entire layout and than zoom to a particular part of the page.</p>
<p>This is nice because news sites as <a title="CNN" href="http://cnn.com/" target="_blank">cnn.com</a> or <a title="Le Monde France" href="http://lemonde.fr/" target="_blank">lemonde.fr</a> are full of text &amp; image information and once zoomed in they fit the screen &#8211; very nice feature of the browsers. However if you&#8217;d like to design a site for mobile the bad part comes here. Yeah you know how to detect the browser, that was a topic of one of my previous posts, but even than you fully functional, but less decorated site is scaled again and looks more ugly than the full version of the site.</p>
<p><a href="/wp-content/uploads/2010/03/mobile.twitter.png"><img class="aligncenter size-full wp-image-1248" title="mobile.twitter" src="/wp-content/uploads/2010/03/mobile.twitter.png" alt="Twitter for mobile" width="320" height="480" srcset="/wp-content/uploads/2010/03/mobile.twitter.png 320w, /wp-content/uploads/2010/03/mobile.twitter-200x300.png 200w" sizes="(max-width: 320px) 100vw, 320px" /></a></p>
<h2>How to make a site visible in mobile &#8230;</h2>
<p>Look at the <a title="Mobile Twitter" href="http://mobile.twitter.com/" target="_blank">http://mobile.twitter.com/</a> &#8211; the problem is that if you open this link with a normal browser, not from mobile, you&#8217;ll get redirected to the twitter.com and you cannot see the difference.</p>
<h2>You can see how it&#8217;s made on &#8230;</h2>
<p>The digg&#8217;s mobile version. Look at <a title="Digg for mobile" href="http://m.digg.com/" target="_blank">http://m.digg.com/</a>. This time you can see the different approach just by looking at the source code. Pay attention to meta tag in the head &#8211; it simply says &#8211; &#8220;don&#8217;t scale&#8221;. Nice thing to notice!</p>
<p>Don&#8217;t scale my site anymore:</p>
<pre lang="html4strict" escaped="true">&lt;html&gt;
 &lt;head&gt;
  &lt;meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/&gt;
 &lt;/head&gt;
...
&lt;/html&gt;</pre>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/03/17/stop-coding-iphone-apps-begin-with-html5-mobile-sites/" rel="bookmark" title="Stop Coding iPhone Apps, Begin with HTML5 Mobile Sites">Stop Coding iPhone Apps, Begin with HTML5 Mobile Sites </a></li>
<li><a href="/2010/03/22/php-mobile-devices-http_user_agent-strings/" rel="bookmark" title="PHP: Mobile Devices HTTP_USER_AGENT Strings">PHP: Mobile Devices HTTP_USER_AGENT Strings </a></li>
<li><a href="/2010/01/31/speed-up-the-javascript-it-can-change-dramatically-the-user-experience/" rel="bookmark" title="Speed up the JavaScript. It can change dramatically the user experience.">Speed up the JavaScript. It can change dramatically the user experience. </a></li>
<li><a href="/2010/08/03/html-tags/" rel="bookmark" title="HTML Tags: &lt;base&gt;">HTML Tags: &lt;base&gt; </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/03/10/change-the-viewport-be-ready-for-the-iphone/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>HTML5 video support. Detecting, playing and progressive enhancement!</title>
		<link>/2010/02/26/html5-video-support-detecting-playing-and-progressive-enhancement/</link>
		<comments>/2010/02/26/html5-video-support-detecting-playing-and-progressive-enhancement/#respond</comments>
		<pubDate>Fri, 26 Feb 2010 13:31:36 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[Adobe Flash Player]]></category>
		<category><![CDATA[Flash Video]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[HTML element]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[Web browser]]></category>

		<guid isPermaLink="false">/?p=1154</guid>
		<description><![CDATA[HTML5 video HTML5 is mentioned as entirely new &#8220;thing&#8221; out in the web, but what it actually means is rather a collection of new, unknown for the current HTML version, features. One of the most interesting and used things in HTML5 are the support of a video in a entirely new &#8220;video&#8221; tag. Until now &#8230; <a href="/2010/02/26/html5-video-support-detecting-playing-and-progressive-enhancement/" class="more-link">Continue reading <span class="screen-reader-text">HTML5 video support. Detecting, playing and progressive enhancement!</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/03/04/does-firefox-play-mp4-h-264-within-the-html5-video-tag/" rel="bookmark" title="Does Firefox play mp4 h.264 within the HTML5 video tag?">Does Firefox play mp4 h.264 within the HTML5 video tag? </a></li>
<li><a href="/2010/01/23/youtube-and-vimeo-goes-html5-with-video-tag-usage-catch-them-up/" rel="bookmark" title="YouTube and Vimeo goes HTML5 with video tag usage! Catch them up!">YouTube and Vimeo goes HTML5 with video tag usage! Catch them up! </a></li>
<li><a href="/2010/03/05/video-sites-must-use-mp4-and-only-mp4/" rel="bookmark" title="Video sites must use &#8230; mp4 and only mp4!">Video sites must use &#8230; mp4 and only mp4! </a></li>
<li><a href="/2011/01/27/few-thoughts-on-web-video/" rel="bookmark" title="Few Thoughts on Web Video">Few Thoughts on Web Video </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>HTML5 video</h2>
<p>HTML5 is mentioned as entirely new &#8220;thing&#8221; out in the web, but what it actually means is rather a collection of new, unknown for the current HTML version, features. One of the most interesting and used things in HTML5 are the support of a video in a entirely new &#8220;video&#8221; tag. Until now the playing of a video was either with Flash player or with Quick Time. But in both cases it relied on a third party plugins. Of course normally the question about performance was inevitable. Which is faster? But imagine we didn&#8217;t have the IMG tag? This give you the answer &#8211; using third party plugins always slows down the page, and today most of the web is based on video sharing and therefore the browsers become slower!</p>
<h2>Performance of HTML5 video tag against Flash video players</h2>
<p>As I mentioned above the performance of HTML5 video should be way better than the performance of any Flash video player. To be more precise I&#8217;ll reference an article from <a title="ajaxian" href="http://ajaxian.com/" target="_blank">ajaxian.com</a>, where the author points on his turn an interesting <a href="http://ajaxian.com/archives/i-cant-believe-its-not-flash" target="_blank">presentation</a>. Indeed the performance of HTML5 video was way, way better:</p>
<p><a href="/wp-content/uploads/2010/02/flashhtml5video.png"><img class="aligncenter size-medium wp-image-1155" title="flashhtml5video" src="/wp-content/uploads/2010/02/flashhtml5video-300x224.png" alt="" width="300" height="224" srcset="/wp-content/uploads/2010/02/flashhtml5video-300x224.png 300w, /wp-content/uploads/2010/02/flashhtml5video.png 504w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>But sometimes this doesn&#8217;t resolves all the problems. Normally with this &#8220;new&#8221; technique of putting a video into the page, come some additional issues.</p>
<p>First of all there are many codecs that the browser should support and almost always there is something &#8220;your&#8221; browser don&#8217;t support. That makes the task bigger. Now you should support more and more video file formats for the different browsers. And yet another problem is the detection of this codec support.</p>
<h2>Detection and integration</h2>
<p>Lucky enough, I found a great article and tutorial describing how to integrate HTML5 video with progressive enhancement. First of all you can check for it&#8217;s support than downgrade to Quick Time and Flash and if the client doesn&#8217;t support even that &#8211; render an image.</p>
<p>You can find the source <a href="http://camendesign.com/code/video_for_everybody" target="_blank">here.</a></p>
<p>Thanks to this technique you can fully integrate new video tag into your page. Remember that most of the clients for sure will be happy to watch video in a more user friendly manner.</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/03/04/does-firefox-play-mp4-h-264-within-the-html5-video-tag/" rel="bookmark" title="Does Firefox play mp4 h.264 within the HTML5 video tag?">Does Firefox play mp4 h.264 within the HTML5 video tag? </a></li>
<li><a href="/2010/01/23/youtube-and-vimeo-goes-html5-with-video-tag-usage-catch-them-up/" rel="bookmark" title="YouTube and Vimeo goes HTML5 with video tag usage! Catch them up!">YouTube and Vimeo goes HTML5 with video tag usage! Catch them up! </a></li>
<li><a href="/2010/03/05/video-sites-must-use-mp4-and-only-mp4/" rel="bookmark" title="Video sites must use &#8230; mp4 and only mp4!">Video sites must use &#8230; mp4 and only mp4! </a></li>
<li><a href="/2011/01/27/few-thoughts-on-web-video/" rel="bookmark" title="Few Thoughts on Web Video">Few Thoughts on Web Video </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/02/26/html5-video-support-detecting-playing-and-progressive-enhancement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery tooltip plugin!</title>
		<link>/2010/02/16/jquery-tooltip-plugin/</link>
		<comments>/2010/02/16/jquery-tooltip-plugin/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 11:43:57 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[Alt attribute]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Graphical user interface]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[HTML element]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[Markup languages]]></category>
		<category><![CDATA[Rel attribute]]></category>
		<category><![CDATA[System software]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[Tooltip]]></category>
		<category><![CDATA[User interface]]></category>
		<category><![CDATA[Widgets]]></category>

		<guid isPermaLink="false">/?p=1099</guid>
		<description><![CDATA[Tooltips and jQuery In order to complete the tooltip post series I decided to make a plugin for jQuery that implements tooltips in the most simple way I was able to find! I have no idea what are the other plugins for tooltips and I never used such plugin, but however I needed one in &#8230; <a href="/2010/02/16/jquery-tooltip-plugin/" class="more-link">Continue reading <span class="screen-reader-text">jQuery tooltip plugin!</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/02/17/clickoutside-jquery-plugin/" rel="bookmark" title="clickoutside jQuery plugin">clickoutside jQuery plugin </a></li>
<li><a href="/2010/06/22/jquery-get-the-selected-option-text/" rel="bookmark" title="jQuery: Get the Selected Option Text">jQuery: Get the Selected Option Text </a></li>
<li><a href="/2009/07/16/jquery-browser-and-os-detection-plugin/" rel="bookmark" title="jQuery browser and OS detection plugin">jQuery browser and OS detection plugin </a></li>
<li><a href="/2010/09/24/2xjquery-select-a-selector/" rel="bookmark" title="2xjQuery: Select a Selector">2xjQuery: Select a Selector </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>Tooltips and jQuery</h2>
<p>In order to complete the tooltip post series I decided to make a plugin for <a title="jquery" href="http://jquery.com/" target="_blank">jQuery</a> that implements tooltips in the most simple way I was able to find! I have no idea what are the other plugins for tooltips and I never used such plugin, but however I needed one in order to complete my task an suddenly I turn it into a plugin.</p>
<p>What I&#8217;d like to hear is requests for improvements and bugs reported, just to make the plugin as useful as possible.</p>
<p>Let&#8217;s start in that post with some primary HTML markup, here are the <a title="jquery tooltip plugin source" href="http://www.stoimen.com/jquery.tooltip.plugin/jquery.tooltip.js" target="_blank">complete source</a> and <a title="jquery tooltip plugin" href="http://www.stoimen.com/jquery.tooltip.plugin/" target="_blank">demo page</a>.</p>
<blockquote>
<pre>&lt;html&gt;
&lt;head&gt;
 &lt;title&gt;jQuery tooltip&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;p&gt;A DIV element wrapped in another DIV that's 800 pixels wide and thus defines the bounds&lt;/p&gt;
&lt;div id="wrap" style="width:800px;border:1px solid blue;"&gt;
 &lt;div id="container" title='test' rel="here's some&lt;br /&gt;HTML and image&lt;br /&gt;&lt;img src='/jquery-logo.png' /&gt;" style="border:1px solid red;"&gt;
 &lt;p&gt;
 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer rhoncus vulputate arcu in mollis. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nulla nunc libero, eleifend in imperdiet lacinia, pellentesque eget turpis. Nulla consectetur augue vulputate arcu porta tempus. Mauris nisl risus, fermentum posuere sodales sed, accumsan in massa. Pellentesque facilisis, felis sit amet vulputate egestas, nibh lacus sollicitudin nulla, non commodo nunc elit et eros. Nulla eu placerat mauris. Phasellus sit amet odio nec dui pharetra pulvinar. Nunc sollicitudin, nisl quis interdum consequat, diam dolor condimentum felis, ac porttitor turpis augue nec sapien. Quisque pulvinar nulla ut elit dapibus in tempus ipsum interdum. Pellentesque feugiat tempus tortor, mollis fringilla ligula faucibus nec. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent cursus ullamcorper lacus. Maecenas at blandit justo. Maecenas adipiscing velit luctus mauris gravida adipiscing. Morbi molestie ipsum metus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec sapien mi, hendrerit sit amet semper ut, condimentum et risus. Nulla facilisi.
 &lt;/p&gt;
 &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;When defined over an image the tooltip gets the text into the alt attribute by default&lt;/p&gt;
&lt;img id="my-img" src="/jquery-logo.png" alt="test" /&gt;
&lt;p&gt;When you attach the .tooltip() method on a link it gets its title attribute for the tooltip by default. Note that you can add more and more links after you attach the .tooltip() method on that class name. This is because the plugin make use of the .live() method of jQuery&lt;/p&gt;
&lt;a href="http://stoimen.com/" title="a title of the link"&gt;Just a link!&lt;/a&gt;</pre>
</blockquote>
<p>And right after that the JavaScript:</p>
<blockquote>
<pre>&lt;!-- include the jQuery library --&gt;
&lt;script src="/jquery-1.3.2.js"&gt;&lt;/script&gt;
&lt;script&gt;
// this is the plugin code. You can copy/paste it at the bottom of the jquery.js library file
(function(jQuery) {
 jQuery.fn.tooltip = function(options) {
 $('body').append('&lt;div id="sstt" style="display:none;"&gt;&lt;/div&gt;');
 if (typeof options == 'undefined') options = {};
 this.live('mousemove', function(e) {

 var att = 'attribute' in options &amp;&amp; $(this).attr(options.attribute);
 if(!att) att = $(this).attr('rel');

 var bbox = 'bbox' in options &amp;&amp; options.bbox;
 if (!bbox) bbox = $(document);

 if ('text' in options &amp;&amp; options.text) att = options.text;

 if ($(this).is('img')) att = $(this).attr('alt');
 if ($(this).is('a')) att = $(this).attr('title');

 var elem = $('#sstt'),csstxt = elem.css('cssText'),ew=elem.width(),dw=bbox.width(),px=e.pageX+10,py=e.pageY+10;
 elem.html(att);
 var eloffset = dw &gt; px+ew &amp;&amp;
 elem.css('cssText', csstxt+';position:absolute;top:'+py+'px;left:'+px+'px;display:block');

 !eloffset &amp;&amp;
 elem.css('cssText', csstxt+';position:absolute;top:'+py+'px;left:'+(dw-ew)+'px;display:block');
 });
 this.live('mouseout', function() {
 $('#sstt').hide();
 });
 };
})(jQuery);</pre>
</blockquote>
<h2>How to setup the options?</h2>
<p>The .tooltip() method has an optional &#8220;options&#8221; parameter that specifies simple parameters for the tooltip itself.</p>
<blockquote>
<pre>{
 attribute : 'rel',
 bbox : $(document),
 text : ''
}</pre>
</blockquote>
<p>By default the plugin uses the REL attribute for the text of the tooltip, but you can override it by setting the options attribute property:</p>
<blockquote>
<pre>var options = { attribute:'title'}</pre>
</blockquote>
<p>Here the tooltip will take the TITLE attribute value. Note that the TITLE attribute is default for anchor tags and the construction above will be default for them. Over links the .tooltip() method gets the ALT attribute.</p>
<p><strong>bbox</strong> is the default bound box for the tooltip. Default value is $(document), but it can be any other jQuery object. Look at the examples bellow.</p>
<p><strong>text</strong> is predefining the tooltip&#8217;s text.</p>
<h2>Finally some examples</h2>
<p>1. Usage with no options. The REL attribute is considered as text for the tooltip and the bound box is the document:</p>
<blockquote>
<pre>$('#container').tooltip();</pre>
</blockquote>
<p>2. Usage with bound box. The REL is yet again considered as text for the tootip and the bound box is passed as argument as a jQuery object.<br />
2.1. The parent element:</p>
<blockquote>
<pre>$('#container').tooltip({bbox:$('#container').parent()});</pre>
</blockquote>
<p>2.2. Explicit defined parent element:</p>
<blockquote>
<pre>$('#container').tooltip({bbox:$('#wrap')});</pre>
</blockquote>
<p>3. Predefine the text of the tooltip:</p>
<blockquote>
<pre>$('#container').tooltip({text:'Hello World!'});</pre>
</blockquote>
<p>3.1.  It can be even HTML formatted text:</p>
<blockquote>
<pre>$('#container').tooltip({text:'Hello &lt;br /&gt; World!'});</pre>
</blockquote>
<p>4. Predefine the attribute. Now the default REL is dismissed and the TITLE is considered for the tooltip:</p>
<blockquote>
<pre>$('#container').tooltip({attribute:'title'});</pre>
</blockquote>
<p>5. Default for image is not REL but the ALT attribute:</p>
<blockquote>
<pre>$('#my-img').tooltip();</pre>
</blockquote>
<p>6. Default for link is not REL, but the TITLE attribute:</p>
<blockquote>
<pre>$('.my-link').tooltip();</pre>
</blockquote>
<p>7. You can even add some links from the same class on the fly, but they are still working, because of the live event binding:</p>
<blockquote>
<pre>$('body').append('&lt;a href="http://stoimen.com/" title="another link"&gt;some other link&lt;/a&gt;');</pre>
</blockquote>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/02/17/clickoutside-jquery-plugin/" rel="bookmark" title="clickoutside jQuery plugin">clickoutside jQuery plugin </a></li>
<li><a href="/2010/06/22/jquery-get-the-selected-option-text/" rel="bookmark" title="jQuery: Get the Selected Option Text">jQuery: Get the Selected Option Text </a></li>
<li><a href="/2009/07/16/jquery-browser-and-os-detection-plugin/" rel="bookmark" title="jQuery browser and OS detection plugin">jQuery browser and OS detection plugin </a></li>
<li><a href="/2010/09/24/2xjquery-select-a-selector/" rel="bookmark" title="2xjQuery: Select a Selector">2xjQuery: Select a Selector </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/02/16/jquery-tooltip-plugin/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Prevent link default action when mousedown and mouseup fires!</title>
		<link>/2010/01/26/prevent-link-default-action-when-mousedown-and-mouseup-fires/</link>
		<comments>/2010/01/26/prevent-link-default-action-when-mousedown-and-mouseup-fires/#respond</comments>
		<pubDate>Tue, 26 Jan 2010 06:17:37 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[DOM events]]></category>
		<category><![CDATA[HTML element]]></category>
		<category><![CDATA[Human Interest]]></category>
		<category><![CDATA[Uniform Resource Identifier]]></category>
		<category><![CDATA[URI scheme]]></category>

		<guid isPermaLink="false">/?p=924</guid>
		<description><![CDATA[What is preventing default? I’m sure you know how to prevent the default action of a link when onclick event is attached to it. Yes, it is a common task and by simply adding a return false; at the end of the method called on click it simply doesn’t call the refresh the page. This &#8230; <a href="/2010/01/26/prevent-link-default-action-when-mousedown-and-mouseup-fires/" class="more-link">Continue reading <span class="screen-reader-text">Prevent link default action when mousedown and mouseup fires!</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/06/07/bind-zend-action-with-non-default-view/" rel="bookmark" title="Bind Zend Action with Non-Default View">Bind Zend Action with Non-Default View </a></li>
<li><a href="/2010/06/23/bind-zend-action-with-non-default-view-part-2/" rel="bookmark" title="Bind Zend Action with Non-Default View &#8211; Part 2">Bind Zend Action with Non-Default View &#8211; Part 2 </a></li>
<li><a href="/2010/06/16/zend-examples-get-parameters-default-value/" rel="bookmark" title="Zend Examples: GET Parameters Default Value">Zend Examples: GET Parameters Default Value </a></li>
<li><a href="/2010/07/07/default-error-handling-in-zend-framework/" rel="bookmark" title="Default Error Handling in Zend Framework">Default Error Handling in Zend Framework </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>What is preventing default?</h2>
<p>I’m sure you know how to prevent the default action of a link when onclick event is attached to it. Yes, it is a common task and by simply adding a return false; at the end of the method called on click it simply doesn’t call the refresh the page. This is really an everyday task. To describe it first, let’s imagine there’s a link with # href value:</p>
<blockquote>
<pre>&lt;a onclick="”myFunc()”" href="”#”"&gt;click here&lt;/a&gt;</pre>
</blockquote>
<p>Than the definition of myFunc() is something like that:</p>
<blockquote>
<pre>function myFunc() {
   ...
   return false;
}</pre>
</blockquote>
<p>If that “return false” part was missing you simply get additional # in the uri of the page and worse &#8211; you may be scrolled to the top of the page, because of the lack of an anchor with empty name.</p>
<p>OK, but we know how to deal it! But what happens when you don’t attach click event but mousedown/mouseup pair? It may seem the same thing but it is not!</p>
<p>When you place return false on both event handlers of the mousedown/up events nothing happens, there is a # on the end of the uri and yes the document is scrolled.</p>
<h2>How the prevent the default action?</h2>
<p>Simply by adding onclick event! We already know that this is working and prevents the default action. Just do the following:</p>
<blockquote>
<pre>$(‘#element_id’).mousedown(function(){
    ...
    return false;
});
$(#element_id’).mouseup(function() {
   ...
   return false;
});

// this doesn’t work like preventing the default refresh
// action until ....
$(‘#element_id’).click(function() {
   return false;
});
// is added</pre>
</blockquote>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/06/07/bind-zend-action-with-non-default-view/" rel="bookmark" title="Bind Zend Action with Non-Default View">Bind Zend Action with Non-Default View </a></li>
<li><a href="/2010/06/23/bind-zend-action-with-non-default-view-part-2/" rel="bookmark" title="Bind Zend Action with Non-Default View &#8211; Part 2">Bind Zend Action with Non-Default View &#8211; Part 2 </a></li>
<li><a href="/2010/06/16/zend-examples-get-parameters-default-value/" rel="bookmark" title="Zend Examples: GET Parameters Default Value">Zend Examples: GET Parameters Default Value </a></li>
<li><a href="/2010/07/07/default-error-handling-in-zend-framework/" rel="bookmark" title="Default Error Handling in Zend Framework">Default Error Handling in Zend Framework </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/01/26/prevent-link-default-action-when-mousedown-and-mouseup-fires/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OBJECT &#038; &#8230; forget about EMBED tag!</title>
		<link>/2010/01/07/object-forget-about-embed-tag/</link>
		<comments>/2010/01/07/object-forget-about-embed-tag/#respond</comments>
		<pubDate>Thu, 07 Jan 2010 07:48:45 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[Cross-platform software]]></category>
		<category><![CDATA[Gecko]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[HTML element]]></category>
		<category><![CDATA[tag]]></category>
		<category><![CDATA[WebKit]]></category>

		<guid isPermaLink="false">/?p=835</guid>
		<description><![CDATA[Actually most of us think about OBJECT and EMBED tags as inseparate pair. The reality is different. In fact you don&#8217;t need to use the EMBED tag. Only by using the OBJECT tag you ensure it will be interpreted correctly by every browser. As you may know, the EMBED tag is supported by Gecko and &#8230; <a href="/2010/01/07/object-forget-about-embed-tag/" class="more-link">Continue reading <span class="screen-reader-text">OBJECT &#038; &#8230; forget about EMBED tag!</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2009/10/30/object-and-embed-tag-position-in-ie/" rel="bookmark" title="object and embed tag position in IE">object and embed tag position in IE </a></li>
<li><a href="/2009/02/22/html-object-and-embed-tags/" rel="bookmark" title="Html object &#038; embed tags">Html object &#038; embed tags </a></li>
<li><a href="/2009/02/23/object-and-embed-tags-revealed/" rel="bookmark" title="object and embed tags revealed">object and embed tags revealed </a></li>
<li><a href="/2010/01/23/youtube-and-vimeo-goes-html5-with-video-tag-usage-catch-them-up/" rel="bookmark" title="YouTube and Vimeo goes HTML5 with video tag usage! Catch them up!">YouTube and Vimeo goes HTML5 with video tag usage! Catch them up! </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>Actually most of us think about OBJECT and EMBED tags as inseparate pair. The reality is different. In fact you don&#8217;t need to use the EMBED tag.</p>
<p>Only by using the OBJECT tag you ensure it will be interpreted correctly by every browser.</p>
<p>As you may know, the EMBED tag is supported by Gecko and WebKit, but not by IE. On the other side the OBJECT tag is supported by every one.</p>
<p>Why than the most common usage is with OBJECT and EMBED? That&#8217;s by me because of misunderstanding of the semantics of those two!</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2009/10/30/object-and-embed-tag-position-in-ie/" rel="bookmark" title="object and embed tag position in IE">object and embed tag position in IE </a></li>
<li><a href="/2009/02/22/html-object-and-embed-tags/" rel="bookmark" title="Html object &#038; embed tags">Html object &#038; embed tags </a></li>
<li><a href="/2009/02/23/object-and-embed-tags-revealed/" rel="bookmark" title="object and embed tags revealed">object and embed tags revealed </a></li>
<li><a href="/2010/01/23/youtube-and-vimeo-goes-html5-with-video-tag-usage-catch-them-up/" rel="bookmark" title="YouTube and Vimeo goes HTML5 with video tag usage! Catch them up!">YouTube and Vimeo goes HTML5 with video tag usage! Catch them up! </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/01/07/object-forget-about-embed-tag/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery live() vs bind() performance</title>
		<link>/2009/12/30/jquery-live-vs-bind-performance/</link>
		<comments>/2009/12/30/jquery-live-vs-bind-performance/#respond</comments>
		<pubDate>Wed, 30 Dec 2009 15:27:06 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[Application programming interfaces]]></category>
		<category><![CDATA[Document Object Model]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[HTML element]]></category>
		<category><![CDATA[JavaScript programming language]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[Span and div]]></category>

		<guid isPermaLink="false">/?p=841</guid>
		<description><![CDATA[1. What is event delegation in JavaScript? To start with some example let&#8217;s assume that there is one DIV element with 100 A tags inside. If you assign event to every A tag that as you may know slowes down your browser. That&#8217;s a problem because sometimes that can happen, even with more than one &#8230; <a href="/2009/12/30/jquery-live-vs-bind-performance/" class="more-link">Continue reading <span class="screen-reader-text">jQuery live() vs bind() performance</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2009/10/08/jquery-the-difference-between-mouseout-and-mouseleave/" rel="bookmark" title="jQuery: the difference between mouseout and mouseleave">jQuery: the difference between mouseout and mouseleave </a></li>
<li><a href="/2009/07/29/cancel-bubbling-on-element-click-with-jquery/" rel="bookmark" title="cancel bubbling on element click with jQuery">cancel bubbling on element click with jQuery </a></li>
<li><a href="/2009/05/25/remove-dom-element-with-jquery/" rel="bookmark" title="Remove DOM Element with JQuery">Remove DOM Element with JQuery </a></li>
<li><a href="/2009/04/01/jquery-accessing-a-child-element/" rel="bookmark" title="jQuery &#8211; accessing a child element">jQuery &#8211; accessing a child element </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>1. What is event delegation in JavaScript?</h2>
<p>To start with some example let&#8217;s assume that there is one DIV element with 100 A tags inside. If you assign event to every A tag that as you may know slowes down your browser. That&#8217;s a problem because sometimes that can happen, even with more than one hundred A tags. Imagine you&#8217;ve a map with one thousand markers, which are A tags. Attaching events slowes down the browser, because every of these A tags bubbles the event that has been fired. And that makes your CPU to make thousands of calculations. Of course you can avoid this problem with a simple technique. Just attach one single event on the container DIV element. Thus you can check if some child of the DIV element has been the target of the event. This makes the browser to breath.<span id="more-841"></span></p>
<h2>2. How event delegation is implemented in jQuery &#8211; $.live()</h2>
<p>In jQuery the so called event delegation is done by the $.live() method. As you may see in the doc pages of jQuery thus you can attach events on a selected element even before that element exists into the DOM. Just because the attached event is on the parent element, and once there are more and more elements attached to it as children, thay behave the same way as those attached before.</p>
<blockquote>
<pre>Example:
$('div &gt; a').live('click', doSomething);</pre>
</blockquote>
<h2>3. bind with $.bind() or $.click, $.mousemove &#8230;</h2>
<p>More common use in jQuery is to attach elements with $.bind or it&#8217;s shortcus $.click, $.mousemove &#8230; etc. The problem is that you have to call them again and again after you add more and more elements to the DOM, because this attach events to the matched elements. Normally when you add more elements they don&#8217;t have any event attached to.</p>
<blockquote>
<pre>Example:
$('div &gt; a').click(doSomething);
// this example does exactly the same thing as the one above,
// but applied on 1000 tags is much slower!</pre>
</blockquote>
<h2>4. Performance</h2>
<p>Of course the performance is better with $.live, but be carefull when playing around with those methods. See more performance results <a href="http://www.ravelrumba.com/blog/event-delegation-jquery-performance/" target="_blank">here</a>.</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2009/10/08/jquery-the-difference-between-mouseout-and-mouseleave/" rel="bookmark" title="jQuery: the difference between mouseout and mouseleave">jQuery: the difference between mouseout and mouseleave </a></li>
<li><a href="/2009/07/29/cancel-bubbling-on-element-click-with-jquery/" rel="bookmark" title="cancel bubbling on element click with jQuery">cancel bubbling on element click with jQuery </a></li>
<li><a href="/2009/05/25/remove-dom-element-with-jquery/" rel="bookmark" title="Remove DOM Element with JQuery">Remove DOM Element with JQuery </a></li>
<li><a href="/2009/04/01/jquery-accessing-a-child-element/" rel="bookmark" title="jQuery &#8211; accessing a child element">jQuery &#8211; accessing a child element </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2009/12/30/jquery-live-vs-bind-performance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
