<?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>Focus &#8211; stoimen&#039;s web log</title>
	<atom:link href="/tag/focus/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>Wanted &#8211; onfocus/onblur. Why They Don&#8217;t Work Always!</title>
		<link>/2011/02/09/wanted-onfocusonblur-why-they-dont-work-always/</link>
		<comments>/2011/02/09/wanted-onfocusonblur-why-they-dont-work-always/#respond</comments>
		<pubDate>Wed, 09 Feb 2011 14:11:48 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[DOM events]]></category>
		<category><![CDATA[Focus]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[Markup languages]]></category>
		<category><![CDATA[Tag soup]]></category>
		<category><![CDATA[Technical communication]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[World Wide Web]]></category>

		<guid isPermaLink="false">/?p=2160</guid>
		<description><![CDATA[On Focus Perhaps you think of onfocus and onblur events as a default behavior existing in any web page. This is not quite true! Onfocurs and onblur are well known in web developing (js) and are fired, of course, when the user tries to point something or leaves some element. Onfocurs is fired when the &#8230; <a href="/2011/02/09/wanted-onfocusonblur-why-they-dont-work-always/" class="more-link">Continue reading <span class="screen-reader-text">Wanted &#8211; onfocus/onblur. Why They Don&#8217;t Work Always!</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="/2009/12/30/jquery-live-vs-bind-performance/" rel="bookmark" title="jQuery live() vs bind() performance">jQuery live() vs bind() performance </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>
<li><a href="/2010/01/20/google-closure-compiler-doesnt-work/" rel="bookmark" title="Google Closure Compiler doesn&#8217;t work?!">Google Closure Compiler doesn&#8217;t work?! </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>On Focus</h2>
<p><a href="/wp-content/uploads/2011/02/onfocus.jpg"><img class="alignleft size-full wp-image-2177" title="onfocus" src="/wp-content/uploads/2011/02/onfocus.jpg" alt="onfocus" width="450" height="253" srcset="/wp-content/uploads/2011/02/onfocus.jpg 450w, /wp-content/uploads/2011/02/onfocus-300x168.jpg 300w" sizes="(max-width: 450px) 100vw, 450px" /></a></p>
<p>Perhaps you think of onfocus and onblur events as a default behavior existing in any web page. This is not quite true! Onfocurs and onblur are well known in web developing (js) and are fired, of course, when the user tries to point something or leaves some element. Onfocurs is fired when the user either goes to an element with the Tab button on with the mouse. When the element is on focus, evidently, the onfocus event is fired. Actually you can see which element is on focus, like an anchor or input, when the element is outlined by the browser by default. In the same scenario, when some element has been on focus and than the user switches to another element, the onblur event is fired. Thus you may guess that this element is no longer on focus.<span id="more-2160"></span></p>
<p>This in general are the onfocus/onblur events. The interesting part is that by default are known as built-in events in every page, but that is wrong.</p>
<h2>Where Are My Events?</h2>
<p>A typical use case is to take the code from some web page, where you&#8217;re sure this works perfectly, you can focus and blur element with no obstacle, but once you paste it inside your markup everything&#8217;s going wrong. Imagine you&#8217;ve the following markup (a typical search box text):</p>
<pre lang="html4strict">
<input type="text" onblur="if(this.value=='') this.value = 'Search in This Site';" onfocus="if(this.value=='Search in This Site') this.value = '';" />
</pre>
<p>This works perfectly until you paste it to your site. And than nothing works correctly. Why? Where&#8217;s the problem?</p>
<h2>Make Them Work</h2>
<p>Actually the problem isn&#8217;t hiding somewhere in the markup above. It&#8217;s in the HTML definition. There are lots of web pages using strict HTML definition, that looks like this:</p>
<pre lang="html4strict">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	...
</head>
<body>
	...
</pre>
<p>while you&#8217;ve to use the pure HTML definition to make onfocus/onblur work.</p>
<p>You&#8217;ve to switch to:</p>
<pre lang="html4strict">
<html>
<head>
	...
</head>
<body>
	...
</pre>
<p>Than you can continue using these useful events!</p>
<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="/2009/12/30/jquery-live-vs-bind-performance/" rel="bookmark" title="jQuery live() vs bind() performance">jQuery live() vs bind() performance </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>
<li><a href="/2010/01/20/google-closure-compiler-doesnt-work/" rel="bookmark" title="Google Closure Compiler doesn&#8217;t work?!">Google Closure Compiler doesn&#8217;t work?! </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2011/02/09/wanted-onfocusonblur-why-they-dont-work-always/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
