<?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>Linea de Codigo &#187; HTML5</title>
	<atom:link href="http://lineadecodigo.com/categoria/html5/feed/" rel="self" type="application/rss+xml" />
	<link>http://lineadecodigo.com</link>
	<description>/* Programación en la red */</description>
	<lastBuildDate>Wed, 16 May 2012 06:00:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Poner música en tu web con HTML5</title>
		<link>http://lineadecodigo.com/html5/poner-musica-en-tu-web-con-html5/</link>
		<comments>http://lineadecodigo.com/html5/poner-musica-en-tu-web-con-html5/#comments</comments>
		<pubDate>Wed, 16 May 2012 06:00:52 +0000</pubDate>
		<dc:creator>Víctor Cuervo</dc:creator>
				<category><![CDATA[HTML5]]></category>
		<category><![CDATA[acc]]></category>
		<category><![CDATA[advanced audio coding]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[controls]]></category>
		<category><![CDATA[mp3]]></category>
		<category><![CDATA[mpeg-1]]></category>
		<category><![CDATA[Ogg]]></category>
		<category><![CDATA[vorbis]]></category>

		<guid isPermaLink="false">http://lineadecodigo.com/?p=4311</guid>
		<description><![CDATA[Una de las cosas que ya está estandarizada en HTML5 es la reproducción de elementos de audio. Es decir, podemos poder música en la web de una forma estándar. Para poder poner música en las webs, HTML5 ha estandarizado el elemento AUDIO. Así que, lo que tendremos que hacer, para poner un archivo de música [...]]]></description>
			<content:encoded><![CDATA[<div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><div class='dd-google1-ajax-load dd-google1-4311'></div><g:plusone size='medium' href='http://lineadecodigo.com/html5/poner-musica-en-tu-web-con-html5/'></g:plusone></div><div class='dd_button'><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http%3A%2F%2Flineadecodigo.com%2Fhtml5%2Fponer-musica-en-tu-web-con-html5%2F" send="false" show_faces="false"  layout="button_count" width="92"  ></fb:like></div><div class='dd_button'><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://lineadecodigo.com/html5/poner-musica-en-tu-web-con-html5/" data-count="horizontal" data-text="Poner música en tu web con HTML5" data-via="" ></a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div></div><div style='clear:both'></div></div><div style='clear:both'></div><p>Una de las cosas que ya está estandarizada en <a href="http://www.manualweb.net/tutorial-html5/" title="Tutorial de HTML5">HTML5</a> es la reproducción de elementos de audio. Es decir, podemos poder música en la web de una forma estándar.</p>
<p>Para poder poner música en las webs, <a href="http://www.manualweb.net/tutorial-html5/" title="Tutorial de HTML5">HTML5</a> ha estandarizado el elemento <a href="http://www.w3api.com/wiki/HTML5:AUDIO" title="Elemento AUDIO de HTML5">AUDIO</a>. Así que, lo que tendremos que hacer, para poner un archivo de música será insertar la siguiente etiqueta:</p>
<pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;audio <a href="http://w3api.com/wiki/HTML:src"><span style="color: #000066;">src</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;cancion&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span>audio&gt;</span></pre>
<p>Por lo tanto, si nuestra canción es "micancion.mp3" el código a utilizar será:</p>
<pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;audio <a href="http://w3api.com/wiki/HTML:src"><span style="color: #000066;">src</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;micancion.mp3&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span>audio&gt;</span></pre>
<p>Si escribimos solamente este código no llegaremos muy lejos ya que, por defecto, el elemento de audio no se muestra. Por lo tanto no podremos utilizar los botones de play, stop, pause,... Así, si queremos que el elemento de <a href="http://www.w3api.com/wiki/HTML5:AUDIO" title="Elemento AUDIO de HTML5">AUDIO</a venga con un reproductor deberemos de añadir el autributo <a href="http://www.w3api.com/wiki/HTML5:AUDIO.controls" title="Atributo controls del elemento AUDIO de HTML5">controls</a>.</p>
<pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;audio <a href="http://w3api.com/wiki/HTML:src"><span style="color: #000066;">src</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;micancion.mp3&quot;</span> controls&gt;&lt;<span style="color: #66cc66;">/</span>audio&gt;</span></pre>
<p>Así ya tendremos el reproductor que nos permita poner la música en nuestra web con <a href="http://www.manualweb.net/tutorial-html5/" title="Tutorial de HTML5">HTML5</a.</p>
<p>Los formatos que podemos reproducir mediante el elemento <a href="http://www.w3api.com/wiki/HTML5:AUDIO" title="Elemento AUDIO de HTML5">AUDIO</a> de <a href="http://www.manualweb.net/tutorial-html5/" title="Tutorial de HTML5">HTML5</a son:</p>
<ul>
<li><strong>MPEG-1 audio layer 3</strong>, que son los más que de sobra conocidos como MP3 y extensión .mp3.</li>
<li><strong>Advanced Audio Coding</strong>, mejoraban la calidad de sonido de los MP3 y es un formato promovido por Apple. Su extensión es .acc. Este formato funciona bajo pantentes</li>
<li><strong>Vorbis</strong>, o conocido como Ogg Vorbis. Es un formato libre de patentes. La extensión que utilizan es .ogg</li>
</ul>
<p><strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://lineadecodigo.com/html/embed-musica-de-fondo-en-tu-pagina-web/" rel="bookmark" title="Marzo 24, 2007">Embed: Música de fondo en tu página web</a></li>
<li><a href="http://lineadecodigo.com/java/reproducir-musica-por-java/" rel="bookmark" title="Abril 24, 2010">Reproducir música por java</a></li>
<li><a href="http://lineadecodigo.com/html5/iniciar-automaticamente-un-video-en-html5/" rel="bookmark" title="Enero 16, 2012">Iniciar automáticamente un vídeo en HTML5</a></li>
<li><a href="http://lineadecodigo.com/html/cargar-un-video-avi-asf-o-wmv-en-mi-pagina-web/" rel="bookmark" title="Agosto 29, 2007">Cargar un vídeo AVI, ASF o WMV en mi página web</a></li>
<li><a href="http://lineadecodigo.com/html/utilizando-la-etiqueta-address/" rel="bookmark" title="Septiembre 8, 2010">Utilizando la etiqueta ADDRESS</a></li>
</ul>
<p><!-- Similar Posts took 7.554 ms --></p>
<script type="text/javascript"> jQuery(document).ready(function($) { window.setTimeout('loadGoogle1_4311()',1000); }); </script><script type="text/javascript"> function loadGoogle1_4311(){ jQuery(document).ready(function($) { $('.dd-google1-4311').remove();$.getScript('https://apis.google.com/js/plusone.js'); }); }</script><!-- Social Buttons Generated by Digg Digg plugin v5.2.6,
    Author : Buffer, Inc
    Website : http://bufferapp.com/diggdigg -->]]></content:encoded>
			<wfw:commentRss>http://lineadecodigo.com/html5/poner-musica-en-tu-web-con-html5/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Autocompletar formularios con HTML5</title>
		<link>http://lineadecodigo.com/html5/autocompletar-formularios-con-html5/</link>
		<comments>http://lineadecodigo.com/html5/autocompletar-formularios-con-html5/#comments</comments>
		<pubDate>Thu, 19 Apr 2012 21:45:10 +0000</pubDate>
		<dc:creator>Víctor Cuervo</dc:creator>
				<category><![CDATA[HTML5]]></category>
		<category><![CDATA[autocomplete]]></category>
		<category><![CDATA[Form]]></category>
		<category><![CDATA[formulario]]></category>

		<guid isPermaLink="false">http://lineadecodigo.com/?p=4088</guid>
		<description><![CDATA[Seguro que cuando estás rellenando un formulario muchas de las veces te empieza a ofrecer opciones de autocompletado de los datos. Empiezas a escribir tu nombre y ya te ofrece varias opciones. E incluso, introduciendo un solo campo te rellena varios del formulario. No en vano el autocompletar de los formularios es una de las [...]]]></description>
			<content:encoded><![CDATA[<div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><div class='dd-google1-ajax-load dd-google1-4088'></div><g:plusone size='medium' href='http://lineadecodigo.com/html5/autocompletar-formularios-con-html5/'></g:plusone></div><div class='dd_button'><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http%3A%2F%2Flineadecodigo.com%2Fhtml5%2Fautocompletar-formularios-con-html5%2F" send="false" show_faces="false"  layout="button_count" width="92"  ></fb:like></div><div class='dd_button'><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://lineadecodigo.com/html5/autocompletar-formularios-con-html5/" data-count="horizontal" data-text="Autocompletar formularios con HTML5" data-via="" ></a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div></div><div style='clear:both'></div></div><div style='clear:both'></div><p>Seguro que cuando estás rellenando un formulario muchas de las veces te empieza a ofrecer opciones de autocompletado de los datos. Empiezas a escribir tu nombre y ya te ofrece varias opciones. E incluso, introduciendo un solo campo te rellena varios del formulario.</p>
<p>No en vano <a href="http://www.ayudaenlaweb.com/navegadores/autorellenar-formularios-con-google-chrome/" title="Autocompletar formularios en Google Chrome">el autocompletar de los formularios es una de las cosas que más está potenciando los navegadores</a>.</p>
<p>Ahora con <a href="http://www.manualweb.net/tutorial-html5/" title="Manual de HTML5">HTML5</a> vamos a poder controlar el aspecto de autocompletar los formularios. Así mediante código podremos decir si queremos que el formulario sea autocompletable o no.</p>
<p>Para controlar el autocompletar de los formularios con <a href="http://www.manualweb.net/tutorial-html5/" title="Manual de HTML5">HTML5</a> tenemos el atributo <a href="http://www.w3api.com/wiki/HTML5:FORM.autocomplete" title="Atributo autocomplete del formulario HTML5">autocomplete</a>. Atributo al cual deberemos de pasar un valor booleano.</p>
<p>Así podemos tener un formulario con el autocompletar del formulario activado. Es decir con el atributo <a href="http://www.w3api.com/wiki/HTML5:FORM.autocomplete" title="Atributo autocomplete del formulario HTML5">autocomplete</a> a "on":</p>
<pre class="html4strict" style="font-family:monospace;">&nbsp;
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:H2"><span style="color: #000000; font-weight: bold;">h2</span></a>&gt;</span>Formulario con Autocompletar Activado<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:H2"><span style="color: #000000; font-weight: bold;">h2</span></a>&gt;</span>
&nbsp;
Al insertar datos en los campos es muy probable que se muestren opciones de autocompletado.
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:FORM"><span style="color: #000000; font-weight: bold;">form</span></a> <a href="http://w3api.com/wiki/HTML:action"><span style="color: #000066;">action</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;enviar.php&quot;</span> autocomplete<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;on&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:LABEL"><span style="color: #000000; font-weight: bold;">label</span></a> <a href="http://w3api.com/wiki/HTML:for"><span style="color: #000066;">for</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nombre&quot;</span>&gt;</span>Nombre: <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:LABEL"><span style="color: #000000; font-weight: bold;">label</span></a>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:INPUT"><span style="color: #000000; font-weight: bold;">input</span></a> <a href="http://w3api.com/wiki/HTML:type"><span style="color: #000066;">type</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nombre&quot;</span><span style="color: #66cc66;">/</span>&gt;&lt;<a href="http://w3api.com/wiki/HTML:BR"><span style="color: #000000; font-weight: bold;">br</span></a><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:LABEL"><span style="color: #000000; font-weight: bold;">label</span></a> <a href="http://w3api.com/wiki/HTML:for"><span style="color: #000066;">for</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;city&quot;</span>&gt;</span>Ciudad: <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:LABEL"><span style="color: #000000; font-weight: bold;">label</span></a>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:INPUT"><span style="color: #000000; font-weight: bold;">input</span></a> <a href="http://w3api.com/wiki/HTML:type"><span style="color: #000066;">type</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;city&quot;</span><span style="color: #66cc66;">/</span>&gt;&lt;<a href="http://w3api.com/wiki/HTML:BR"><span style="color: #000000; font-weight: bold;">br</span></a><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:FORM"><span style="color: #000000; font-weight: bold;">form</span></a>&gt;</span>
&nbsp;</pre>
<p>O un formulario con el autocompletar del formulario desactivado. Es decir, con el atributo <a href="http://www.w3api.com/wiki/HTML5:FORM.autocomplete" title="Atributo autocomplete del formulario HTML5">autocomplete</a> a "off":</p>
<pre class="html4strict" style="font-family:monospace;">&nbsp;
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:H2"><span style="color: #000000; font-weight: bold;">h2</span></a>&gt;</span>Formulario con Autocompletar Desactivado<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:H2"><span style="color: #000000; font-weight: bold;">h2</span></a>&gt;</span>
&nbsp;
Al insertar datos en los campos no se te mostraran opciones de autocompletado.
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:FORM"><span style="color: #000000; font-weight: bold;">form</span></a> <a href="http://w3api.com/wiki/HTML:action"><span style="color: #000066;">action</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;enviar.php&quot;</span> autocomplete<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;off&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:LABEL"><span style="color: #000000; font-weight: bold;">label</span></a> <a href="http://w3api.com/wiki/HTML:for"><span style="color: #000066;">for</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nombre2&quot;</span>&gt;</span>Nombre: <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:LABEL"><span style="color: #000000; font-weight: bold;">label</span></a>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:INPUT"><span style="color: #000000; font-weight: bold;">input</span></a> <a href="http://w3api.com/wiki/HTML:type"><span style="color: #000066;">type</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nombre2&quot;</span><span style="color: #66cc66;">/</span>&gt;&lt;<a href="http://w3api.com/wiki/HTML:BR"><span style="color: #000000; font-weight: bold;">br</span></a><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:LABEL"><span style="color: #000000; font-weight: bold;">label</span></a> <a href="http://w3api.com/wiki/HTML:for"><span style="color: #000066;">for</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;city2&quot;</span>&gt;</span>Ciudad: <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:LABEL"><span style="color: #000000; font-weight: bold;">label</span></a>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:INPUT"><span style="color: #000000; font-weight: bold;">input</span></a> <a href="http://w3api.com/wiki/HTML:type"><span style="color: #000066;">type</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;city2&quot;</span><span style="color: #66cc66;">/</span>&gt;&lt;<a href="http://w3api.com/wiki/HTML:BR"><span style="color: #000000; font-weight: bold;">br</span></a><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:FORM"><span style="color: #000000; font-weight: bold;">form</span></a>&gt;</span>
&nbsp;</pre>
<p>Un simple atributo en <a href="http://www.manualweb.net/tutorial-html5/" title="Manual de HTML5">HTML5</a> con mucha capacidad de control.<strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://lineadecodigo.com/asp/recuperar-datos-de-un-formulario-con-asp/" rel="bookmark" title="Marzo 8, 2009">Recuperar datos de un formulario con ASP</a></li>
<li><a href="http://lineadecodigo.com/jquery/modificar-valores-por-defecto-de-un-formulario-con-jquery/" rel="bookmark" title="Marzo 15, 2011">Modificar valores por defecto de un formulario con jQuery</a></li>
<li><a href="http://lineadecodigo.com/jquery/listar-opciones-seleccionadas-de-un-combo-con-jquery/" rel="bookmark" title="Septiembre 24, 2011">Listar opciones seleccionadas de un combo con jQuery</a></li>
<li><a href="http://lineadecodigo.com/php/recuperar-datos-de-un-formulario-con-php/" rel="bookmark" title="Enero 3, 2010">Recuperar datos de un formulario con PHP</a></li>
<li><a href="http://lineadecodigo.com/html5/controlar-volumen-de-video-html5-con-un-slider/" rel="bookmark" title="Febrero 3, 2012">Controlar volumen de vídeo HTML5 con un Slider</a></li>
</ul>
<p><!-- Similar Posts took 7.418 ms --></p>
<script type="text/javascript"> jQuery(document).ready(function($) { window.setTimeout('loadGoogle1_4088()',1000); }); </script><script type="text/javascript"> function loadGoogle1_4088(){ jQuery(document).ready(function($) { $('.dd-google1-4088').remove();$.getScript('https://apis.google.com/js/plusone.js'); }); }</script><!-- Social Buttons Generated by Digg Digg plugin v5.2.6,
    Author : Buffer, Inc
    Website : http://bufferapp.com/diggdigg -->]]></content:encoded>
			<wfw:commentRss>http://lineadecodigo.com/html5/autocompletar-formularios-con-html5/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Crear un documento editable con HTML5</title>
		<link>http://lineadecodigo.com/html5/crear-un-documento-editable-con-html5/</link>
		<comments>http://lineadecodigo.com/html5/crear-un-documento-editable-con-html5/#comments</comments>
		<pubDate>Tue, 20 Mar 2012 07:00:09 +0000</pubDate>
		<dc:creator>Víctor Cuervo</dc:creator>
				<category><![CDATA[HTML5]]></category>
		<category><![CDATA[designMode]]></category>
		<category><![CDATA[documento]]></category>
		<category><![CDATA[editable]]></category>

		<guid isPermaLink="false">http://lineadecodigo.com/?p=3988</guid>
		<description><![CDATA[Ya veíamos en otro artículo como en HTML5 tenemos la capacidad de definir áreas o elementos que sean editables. Para ello nos basábamos en el atributo general de HTML5 contentEditable. Pero con HTML5 podemos llegar aún más lejos y podemos crear un documento editable. Es decir, que todos los elementos de la página serán editables [...]]]></description>
			<content:encoded><![CDATA[<div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><div class='dd-google1-ajax-load dd-google1-3988'></div><g:plusone size='medium' href='http://lineadecodigo.com/html5/crear-un-documento-editable-con-html5/'></g:plusone></div><div class='dd_button'><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http%3A%2F%2Flineadecodigo.com%2Fhtml5%2Fcrear-un-documento-editable-con-html5%2F" send="false" show_faces="false"  layout="button_count" width="92"  ></fb:like></div><div class='dd_button'><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://lineadecodigo.com/html5/crear-un-documento-editable-con-html5/" data-count="horizontal" data-text="Crear un documento editable con HTML5" data-via="" ></a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div></div><div style='clear:both'></div></div><div style='clear:both'></div><p>Ya veíamos en otro artículo como <a href="http://lineadecodigo.com/html5/crear-contenido-editable-en-html5/" title="Contenido Editable en HTML5">en HTML5 tenemos la capacidad de definir áreas o elementos que sean editables</a>. Para ello nos basábamos en el atributo general de <a href="http://www.manualweb.net/tutorial-html5/" title="Manual de HTML5">HTML5</a> <a href="http://www.w3api.com/wiki/HTML5:ContentEditable" title="Atributo HTML5 contentEditable">contentEditable</a>.</p>
<p>Pero con <a href="http://www.manualweb.net/tutorial-html5/" title="Manual de HTML5">HTML5</a> podemos llegar aún más lejos y podemos crear un documento editable. Es decir, que todos los elementos de la página serán editables desde nuestro navegador.</p>
<p>Para poder crear nuestro documento editable en <a href="http://www.manualweb.net/tutorial-html5/" title="Manual de HTML5">HTML5</a> deberemos de recurrir al <a href="http://www.manualweb.net/tutorial-javascript/" title="Manual de Javascript">Javascript</a> y es que desde código <a href="http://www.manualweb.net/tutorial-javascript/" title="Manual de Javascript">Javascript</a> podemos modificar el atributo designMode y aplicarle el valor "on".</p>
<pre class="javascript" style="font-family:monospace;">document.<span style="color: #660066;">designMode</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;on&quot;</span><span style="color: #339933;">;</span></pre>
<p>Esta simple línea de código Javascript que modifica un atributo <a href="http://www.manualweb.net/tutorial-html5/" title="Manual de HTML5">HTML5</a> permite que el documento entero sea editable.</p>
<p>No he encontrado forma de hacerlo directamente sobre el código <a href="http://www.manualweb.net/tutorial-html5/" title="Manual de HTML5">HTML5</a> de la página, sin recurrir al código <a href="http://www.manualweb.net/tutorial-javascript/" title="Manual de Javascript">Javascript</a>. Si alguien sabe como resolverlo, su respuesta será muy bienvenida.<strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://lineadecodigo.com/html5/crear-contenido-editable-en-html5/" rel="bookmark" title="Febrero 28, 2012">Crear contenido editable en HTML5</a></li>
<li><a href="http://lineadecodigo.com/html/generar-un-documento-html-mediante-javascript/" rel="bookmark" title="Junio 28, 2007">Generar un documento HTML mediante JavaScript</a></li>
<li><a href="http://lineadecodigo.com/javascript/obtener-el-titulo-de-la-pagina-con-javascript/" rel="bookmark" title="Junio 16, 2007">Obtener el titulo de la página con JavaScript</a></li>
<li><a href="http://lineadecodigo.com/javascript/calcular-el-numero-de-imagenes-con-javascript/" rel="bookmark" title="Julio 4, 2007">Calcular el numero de imagenes con JavaScript</a></li>
<li><a href="http://lineadecodigo.com/html5/autofoco-a-un-campo-con-html5/" rel="bookmark" title="Febrero 5, 2012">Autofoco a un campo con HTML5</a></li>
</ul>
<p><!-- Similar Posts took 8.800 ms --></p>
<script type="text/javascript"> jQuery(document).ready(function($) { window.setTimeout('loadGoogle1_3988()',1000); }); </script><script type="text/javascript"> function loadGoogle1_3988(){ jQuery(document).ready(function($) { $('.dd-google1-3988').remove();$.getScript('https://apis.google.com/js/plusone.js'); }); }</script><!-- Social Buttons Generated by Digg Digg plugin v5.2.6,
    Author : Buffer, Inc
    Website : http://bufferapp.com/diggdigg -->]]></content:encoded>
			<wfw:commentRss>http://lineadecodigo.com/html5/crear-un-documento-editable-con-html5/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Activar el corrector ortográfico con HTML5</title>
		<link>http://lineadecodigo.com/html5/activar-el-corrector-ortografico-con-html5/</link>
		<comments>http://lineadecodigo.com/html5/activar-el-corrector-ortografico-con-html5/#comments</comments>
		<pubDate>Tue, 06 Mar 2012 22:50:16 +0000</pubDate>
		<dc:creator>Víctor Cuervo</dc:creator>
				<category><![CDATA[HTML5]]></category>
		<category><![CDATA[corrector ortográfico]]></category>
		<category><![CDATA[spellcheck]]></category>
		<category><![CDATA[textarea]]></category>

		<guid isPermaLink="false">http://lineadecodigo.com/?p=3927</guid>
		<description><![CDATA[La verdad es que casi todos los navegadores modernos ya incluyen dentro de sus plataformas un corrector ortográfico. Algo que no sucedía en las versiones más antiguas. Una de las cosas que podemos hacer gracias a HTML5 es la de activar o desactivar el corrector ortográfico sobre un determinado elemento. Es decir, pasamos a tener [...]]]></description>
			<content:encoded><![CDATA[<div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><div class='dd-google1-ajax-load dd-google1-3927'></div><g:plusone size='medium' href='http://lineadecodigo.com/html5/activar-el-corrector-ortografico-con-html5/'></g:plusone></div><div class='dd_button'><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http%3A%2F%2Flineadecodigo.com%2Fhtml5%2Factivar-el-corrector-ortografico-con-html5%2F" send="false" show_faces="false"  layout="button_count" width="92"  ></fb:like></div><div class='dd_button'><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://lineadecodigo.com/html5/activar-el-corrector-ortografico-con-html5/" data-count="horizontal" data-text="Activar el corrector ortográfico con HTML5" data-via="" ></a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div></div><div style='clear:both'></div></div><div style='clear:both'></div><p>La verdad es que casi todos los navegadores modernos ya incluyen dentro de sus plataformas un corrector ortográfico. Algo que no sucedía en las versiones más antiguas.</p>
<p>Una de las cosas que podemos hacer gracias a <a href="http://www.manualweb.net/tutorial-html5/" title="Manual de HTML5">HTML5</a> es la de activar o desactivar el corrector ortográfico sobre un determinado elemento. Es decir, pasamos a tener control de esta característica del navegador.</p>
<p>El atributo que nos da el control sobre el corrector ortográfico con <a href="http://www.manualweb.net/tutorial-html5/" title="Manual de HTML5">HTML5</a> es <a href="http://www.w3api.com/wiki/HTML5:Spellcheck" title="Atributo HTML5 spellcheck">spellcheck</a>. El atributo <a href="http://www.w3api.com/wiki/HTML5:Spellcheck" title="Atributo HTML5 spellcheck">spellcheck</a> está presente en todos los elementos del lenguaje <a href="http://www.manualweb.net/tutorial-html5/" title="Manual de HTML5">HTML5</a>. Los valores que puede tomar este atributo son "true" y "false". En el primer caso es para activar el corrector ortográfico y en el segundo caso es para deshabilitarlo. Por defecto, el valor que tiene este atributo es "true".</p>
<p>Así, si queremos inhabilitar el corrector ortográfico sobre un área de texto escribiríamos lo siguiente:</p>
<pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:TEXTAREA"><span style="color: #000000; font-weight: bold;">textarea</span></a> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;texto&quot;</span> <a href="http://w3api.com/wiki/HTML:rows"><span style="color: #000066;">rows</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;12&quot;</span> <a href="http://w3api.com/wiki/HTML:cols"><span style="color: #000066;">cols</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;100&quot;</span> spellcheck<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;false&quot;</span>&gt;</span>Texto<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:TEXTAREA"><span style="color: #000000; font-weight: bold;">textarea</span></a>&gt;</span></pre>
<p>Pero no solo podemos jugar con los valores de este atributo en el código <a href="http://www.manualweb.net/tutorial-html5/" title="Manual de HTML5">HTML5</a>, si no que de forma dinámica, mediante <a href="http://www.manualweb.net/tutorial-javascript/" title="Manual de Javascript">Javascript</a>, podemos modificar sus valores.</p>
<p>De esta forma vamos a añadir unos botones para habilitar y deshabilitar el corrector.</p>
<pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:BUTTON"><span style="color: #000000; font-weight: bold;">button</span></a> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;validar&quot;</span>&gt;</span>Validar la Ortografía<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:BUTTON"><span style="color: #000000; font-weight: bold;">button</span></a>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:BUTTON"><span style="color: #000000; font-weight: bold;">button</span></a> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;novalidar&quot;</span>&gt;</span>Quitar la Validación<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:BUTTON"><span style="color: #000000; font-weight: bold;">button</span></a>&gt;</span></pre>
<p>Ahora lo que haremos será capturar los eventos click de dichos botones para activar y desactivar el corrector respectivamente.</p>
<pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> boton <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;validar&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> boton2 <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;novalidar&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> texto <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;texto&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
boton.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;click&quot;</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>ev<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  texto.<span style="color: #660066;">spellcheck</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
  texto.<span style="color: #000066;">focus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
boton2.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;click&quot;</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>ev<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  texto.<span style="color: #660066;">spellcheck</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
  texto.<span style="color: #000066;">focus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;</pre>
<p>Vemos que sobre el elemento <a href="http://www.w3api.com/wiki/HTML:TEXTAREA" title="Elemento HTML Textarea">textarea</a>, del cual obtenemos la referencia con <a href="http://www.w3api.com/wiki/DOM:Document.getElementById()" title="Método javascript getElementById">.getElementById</a>, manipulamos su atributo spellcheck asignándole "true" o "false".<strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://lineadecodigo.com/javascript/convertir-una-cadena-a-fecha-en-javascript/" rel="bookmark" title="Enero 29, 2012">Convertir una cadena a fecha en Javascript</a></li>
<li><a href="http://lineadecodigo.com/html5/tiempo-total-de-un-video-html5/" rel="bookmark" title="Febrero 2, 2012">Tiempo total de un vídeo HTML5</a></li>
<li><a href="http://lineadecodigo.com/html5/elemento-rango-en-formularios-html5/" rel="bookmark" title="Enero 31, 2012">Elemento rango en formularios HTML5</a></li>
<li><a href="http://lineadecodigo.com/html5/menu-contextual-en-html5/" rel="bookmark" title="Febrero 14, 2012">Menú Contextual en HTML5</a></li>
<li><a href="http://lineadecodigo.com/html5/controlar-volumen-de-video-html5-con-un-slider/" rel="bookmark" title="Febrero 3, 2012">Controlar volumen de vídeo HTML5 con un Slider</a></li>
</ul>
<p><!-- Similar Posts took 8.594 ms --></p>
<script type="text/javascript"> jQuery(document).ready(function($) { window.setTimeout('loadGoogle1_3927()',1000); }); </script><script type="text/javascript"> function loadGoogle1_3927(){ jQuery(document).ready(function($) { $('.dd-google1-3927').remove();$.getScript('https://apis.google.com/js/plusone.js'); }); }</script><!-- Social Buttons Generated by Digg Digg plugin v5.2.6,
    Author : Buffer, Inc
    Website : http://bufferapp.com/diggdigg -->]]></content:encoded>
			<wfw:commentRss>http://lineadecodigo.com/html5/activar-el-corrector-ortografico-con-html5/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Crear contenido editable en HTML5</title>
		<link>http://lineadecodigo.com/html5/crear-contenido-editable-en-html5/</link>
		<comments>http://lineadecodigo.com/html5/crear-contenido-editable-en-html5/#comments</comments>
		<pubDate>Tue, 28 Feb 2012 07:00:38 +0000</pubDate>
		<dc:creator>Víctor Cuervo</dc:creator>
				<category><![CDATA[HTML5]]></category>
		<category><![CDATA[contenido]]></category>
		<category><![CDATA[contentEditable]]></category>
		<category><![CDATA[DIV]]></category>
		<category><![CDATA[editor web]]></category>
		<category><![CDATA[textarea]]></category>
		<category><![CDATA[texto enriquecido]]></category>

		<guid isPermaLink="false">http://lineadecodigo.com/?p=3915</guid>
		<description><![CDATA[Una de las nuevas capacidades que encontramos dentro de HTML5 es la de definir un contenido editable. Es decir, nos permite insertar elementos dentro del documento web los cuales el usuario puede editar desde el navegador y modificar su contenido. Lógicamente ampliando las capacidades ya existentes con el TEXTAREA para introducir texto. Así al poder [...]]]></description>
			<content:encoded><![CDATA[<div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><div class='dd-google1-ajax-load dd-google1-3915'></div><g:plusone size='medium' href='http://lineadecodigo.com/html5/crear-contenido-editable-en-html5/'></g:plusone></div><div class='dd_button'><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http%3A%2F%2Flineadecodigo.com%2Fhtml5%2Fcrear-contenido-editable-en-html5%2F" send="false" show_faces="false"  layout="button_count" width="92"  ></fb:like></div><div class='dd_button'><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://lineadecodigo.com/html5/crear-contenido-editable-en-html5/" data-count="horizontal" data-text="Crear contenido editable en HTML5" data-via="" ></a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div></div><div style='clear:both'></div></div><div style='clear:both'></div><p>Una de las nuevas capacidades que encontramos dentro de <a href="http://www.manualweb.net/tutorial-html5/" title="Manual de HTML5">HTML5</a> es la de definir un contenido editable. Es decir, nos permite insertar elementos dentro del documento web los cuales el usuario puede editar desde el navegador y modificar su contenido.</p>
<p>Lógicamente ampliando las capacidades ya existentes con el <a href="http://www.w3api.com/wiki/HTML:TEXTAREA" title="Elemento TEXTAREA de HTML">TEXTAREA</a> para introducir texto. Así al poder crear contenido editable en <a href="http://www.manualweb.net/tutorial-html5/" title="Manual de HTML5">HTML5</a> podremos estar cerca de tener un editor web (o diseñador web) de las páginas web o editores de texto con formato enriquecido.</p>
<p>La forma de crear contenido editable en <a href="http://www.manualweb.net/tutorial-html5/" title="Manual de HTML5">HTML5</a> es muy sencilla. Lo primero que haremos será definir una <a href="http://www.w3api.com/wiki/HTML:DIV" title="Elemento DIV de HTML">capa de contenido DIV</a>. Sobre dicha capa insertaremos texto.</p>
<pre class="html4strict" style="font-family:monospace;">&nbsp;
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:DIV"><span style="color: #000000; font-weight: bold;">div</span></a> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;micapa&quot;</span> <a href="http://w3api.com/wiki/HTML:style"><span style="color: #000066;">style</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;border: thin solid;padding:10px;&quot;</span>&gt;</span>
Inserta la pregunta que quieras hacernos...
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:DIV"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span>
&nbsp;</pre>
<p>Podemos observar que hemos dado un pequeño estilo a la capa agregandola un borde y un espaciado del contenido con respecto al borde.</p>
<p>Para convertir a la capa en editable y así poder crear contenido editbale nos bastará con añadir el atributo <a href="http://www.w3api.com/wiki/HTML5:ContentEditable" title="Atributo contentEditable de HTML5">contentEditable</a> y asignarle un valor de true. Ya que por defecto este atributo vendrá con un valor de false.</p>
<pre class="html4strict" style="font-family:monospace;">&nbsp;
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:DIV"><span style="color: #000000; font-weight: bold;">div</span></a> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;micapa&quot;</span> contentEditable<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;true&quot;</span> <a href="http://w3api.com/wiki/HTML:style"><span style="color: #000066;">style</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;border: thin solid;padding:10px;&quot;</span>&gt;</span>
Inserta la pregunta que quieras hacernos...
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:DIV"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span>
&nbsp;</pre>
<p>Simplemente con la inclusión de este <a href="http://www.w3api.com/wiki/HTML5:ContentEditable" title="Atributo contentEditable de HTML5">contentEditable</a> hemos conseguido crear contenido editable en <a href="http://www.manualweb.net/tutorial-html5/" title="Manual de HTML5">HTML5</a>. Ahora cuando carguemos la página en el navegador y pulsemos sobre el texto veremos como el navegador nos deja modificar el contenido de la capa.</p>
<p>Como siempre con la especificación <a href="http://www.manualweb.net/tutorial-html5/" title="Manual de HTML5">HTML5</a> (al menos de momento), deberemos de tener cuidado con el soporte de los navegadores del atributo <a href="http://www.w3api.com/wiki/HTML5:ContentEditable" title="Atributo contentEditable de HTML5">contentEditable</a>, ya que nos podemos encontrar que alguna versión no lo soporte.<strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://lineadecodigo.com/html5/crear-un-documento-editable-con-html5/" rel="bookmark" title="Marzo 20, 2012">Crear un documento editable con HTML5</a></li>
<li><a href="http://lineadecodigo.com/javascript/modernizr-y-las-capacidades-html5-y-css3/" rel="bookmark" title="Enero 3, 2012">Modernizr y las capacidades HTML5 y CSS3</a></li>
<li><a href="http://lineadecodigo.com/css/controlando-el-overflow-de-una-capa/" rel="bookmark" title="Septiembre 12, 2010">Controlando el overflow de una capa</a></li>
<li><a href="http://lineadecodigo.com/html5/modificando-propiedades-css-con-un-slider/" rel="bookmark" title="Febrero 23, 2012">Modificando propiedades CSS con un Slider</a></li>
<li><a href="http://lineadecodigo.com/jquery/modificar-el-contenido-de-una-capa-con-jquery/" rel="bookmark" title="Mayo 27, 2010">Modificar el contenido de una capa con jQuery</a></li>
</ul>
<p><!-- Similar Posts took 8.227 ms --></p>
<script type="text/javascript"> jQuery(document).ready(function($) { window.setTimeout('loadGoogle1_3915()',1000); }); </script><script type="text/javascript"> function loadGoogle1_3915(){ jQuery(document).ready(function($) { $('.dd-google1-3915').remove();$.getScript('https://apis.google.com/js/plusone.js'); }); }</script><!-- Social Buttons Generated by Digg Digg plugin v5.2.6,
    Author : Buffer, Inc
    Website : http://bufferapp.com/diggdigg -->]]></content:encoded>
			<wfw:commentRss>http://lineadecodigo.com/html5/crear-contenido-editable-en-html5/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Modificando propiedades CSS con un Slider</title>
		<link>http://lineadecodigo.com/html5/modificando-propiedades-css-con-un-slider/</link>
		<comments>http://lineadecodigo.com/html5/modificando-propiedades-css-con-un-slider/#comments</comments>
		<pubDate>Thu, 23 Feb 2012 07:00:15 +0000</pubDate>
		<dc:creator>Víctor Cuervo</dc:creator>
				<category><![CDATA[HTML5]]></category>
		<category><![CDATA[border-radiux]]></category>
		<category><![CDATA[borderRadius]]></category>
		<category><![CDATA[font-size]]></category>
		<category><![CDATA[hoja de estilos]]></category>
		<category><![CDATA[onChange]]></category>
		<category><![CDATA[slider]]></category>

		<guid isPermaLink="false">http://lineadecodigo.com/?p=3889</guid>
		<description><![CDATA[Una de las aplicaciones que podemos tener con un Slider es la de modificar los valores de las propiedades CSS. Así los incrementaremos o decrementaremos, según vayamos moviendo el slider, aplicarán a ciertos valores de las hojas de estilo. En nuestro caso lo que vamos a hacer es modificar el tamaño del texto (font-size) y [...]]]></description>
			<content:encoded><![CDATA[<div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><div class='dd-google1-ajax-load dd-google1-3889'></div><g:plusone size='medium' href='http://lineadecodigo.com/html5/modificando-propiedades-css-con-un-slider/'></g:plusone></div><div class='dd_button'><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http%3A%2F%2Flineadecodigo.com%2Fhtml5%2Fmodificando-propiedades-css-con-un-slider%2F" send="false" show_faces="false"  layout="button_count" width="92"  ></fb:like></div><div class='dd_button'><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://lineadecodigo.com/html5/modificando-propiedades-css-con-un-slider/" data-count="horizontal" data-text="Modificando propiedades CSS con un Slider" data-via="" ></a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div></div><div style='clear:both'></div></div><div style='clear:both'></div><p>Una de las aplicaciones que podemos tener con un Slider es la de modificar los valores de las propiedades <a href="http://www.manualweb.net/tutorial-css/" title="Manual de CSS">CSS</a>. Así los incrementaremos o decrementaremos, según vayamos moviendo el slider, aplicarán a ciertos valores de las hojas de estilo.</p>
<p>En nuestro caso lo que vamos a hacer es modificar el tamaño del texto (<a href="http://www.w3api.com/wiki/CSS:Font-size" title="font-size en css">font-size</a>) y el redonde de las esquinas (<a href="http://www.w3api.com/wiki/CSS:Border-radius" title="border-radiux en css">border-radiux</a>).</p>
<p>Lo primero será crear la página web, la cual contendrá una capa con un texto dentro.</p>
<pre class="html4strict" style="font-family:monospace;">&nbsp;
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:DIV"><span style="color: #000000; font-weight: bold;">div</span></a> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;micapa&quot;</span>&gt;</span>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus venenatis est sit amet nulla imperdiet vestibulum...<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:DIV"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span>
&nbsp;</pre>
<p>Y debajo el <a href="http://lineadecodigo.com/html5/elemento-rango-en-formularios-html5/" title="Cómo crear un slider con HTML5">slider en HTML5</a>:</p>
<pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:LABEL"><span style="color: #000000; font-weight: bold;">label</span></a> <a href="http://w3api.com/wiki/HTML:for"><span style="color: #000066;">for</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;mislider&quot;</span>&gt;</span>Redondea los bordes:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:LABEL"><span style="color: #000000; font-weight: bold;">label</span></a>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:INPUT"><span style="color: #000000; font-weight: bold;">input</span></a> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;mislider&quot;</span> <a href="http://w3api.com/wiki/HTML:type"><span style="color: #000066;">type</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;range&quot;</span> min<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">0</span> max<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">20</span> <a href="http://w3api.com/wiki/HTML:value"><span style="color: #000066;">value</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;6&quot;</span>&gt;</span></pre>
<p>Ahora vamos a empezar a crear el código de manejo. Para ello vamos a controlar el evento onchange del slider.</p>
<pre class="javascript" style="font-family:monospace;">barra.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;change&quot;</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>ev<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
...
<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
<p>El código de este manejador será sencillo ya que lo que hará será modificar una propiedad <a href="http://www.manualweb.net/tutorial-css/" title="Manual de CSS">CSS</a>. Bueno, en realidad, dos. Así que vamos a ver dos formas de modificar las propiedades <a href="http://www.manualweb.net/tutorial-css/" title="Manual de CSS">CSS</a>.</p>
<p>La primera forma será modificando el atributo de un objeto. Es decir, el borde de un estilo está representado por el campo .borderRadius. Así que solo tendremos que asignarle un valor.</p>
<pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> barra <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;mislider&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
resultado <span style="color: #339933;">=</span> barra.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
fuente <span style="color: #339933;">=</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> capa <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;micapa&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> tamanio <span style="color: #339933;">=</span> fuente<span style="color: #339933;">*</span>resultado<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;px&quot;</span><span style="color: #339933;">;</span>
capa.<span style="color: #660066;">style</span>.<span style="color: #660066;">borderRadius</span> <span style="color: #339933;">=</span> tamanio<span style="color: #339933;">;</span></pre>
<p>Si miramos el código vemos que lo primero que hacemos es coger el valor de la barra mediante el atributo value. Este valor lo vamos a multiplicar por una base y se lo aplicamos al estilo.</p>
<p>La segunda forma es mediante el método .setAttribute(). En este caso lo que hacemos es pasarle el nombre del atributo a modificar "style" y la propiedad <a href="http://www.manualweb.net/tutorial-css/" title="Manual de CSS">CSS</a> que queremos modificar.</p>
<pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> barra <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;mislider&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> fuente <span style="color: #339933;">=</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">;</span>
resultado <span style="color: #339933;">=</span> barra.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> capa <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;micapa&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> tamanio <span style="color: #339933;">=</span> fuente<span style="color: #339933;">*</span>resultado<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;px&quot;</span><span style="color: #339933;">;</span>
capa.<span style="color: #660066;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;style&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;font-size:&quot;</span><span style="color: #339933;">+</span>tamanio<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
<p>Todo nuestro código quedará de la siguiente forma:</p>
<pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> barra <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;mislider&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> fuente <span style="color: #339933;">=</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">;</span>
barra.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;change&quot;</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>ev<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	resultado <span style="color: #339933;">=</span> barra.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> capa <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;micapa&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> tamanio <span style="color: #339933;">=</span> fuente<span style="color: #339933;">*</span>resultado<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;px&quot;</span><span style="color: #339933;">;</span>
	capa.<span style="color: #660066;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;style&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;font-size:&quot;</span><span style="color: #339933;">+</span>tamanio<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	capa.<span style="color: #660066;">style</span>.<span style="color: #660066;">borderRadius</span> <span style="color: #339933;">=</span> tamanio<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
<p>¿Qué te ha parecido este uso del slider de <a href="http://www.manualweb.net/tutorial-html5/" title="Manual de HTML5">HTML5</a>? ¿Se te ocurren otros?<strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://lineadecodigo.com/css/formato-de-texto-por-defecto-con-css/" rel="bookmark" title="Diciembre 5, 2007">Formato de texto por defecto con CSS</a></li>
<li><a href="http://lineadecodigo.com/html5/elemento-rango-en-formularios-html5/" rel="bookmark" title="Enero 31, 2012">Elemento rango en formularios HTML5</a></li>
<li><a href="http://lineadecodigo.com/html5/controlar-volumen-de-video-html5-con-un-slider/" rel="bookmark" title="Febrero 3, 2012">Controlar volumen de vídeo HTML5 con un Slider</a></li>
<li><a href="http://lineadecodigo.com/javascript/cambiar-el-contenido-de-una-capa-con-javascript/" rel="bookmark" title="Marzo 3, 2008">Cambiar el contenido de una capa con JavaScript</a></li>
<li><a href="http://lineadecodigo.com/javascript/cambiar-estilos-dinamicamente/" rel="bookmark" title="Septiembre 12, 2009">Cambiar estilos dinámicamente</a></li>
</ul>
<p><!-- Similar Posts took 8.785 ms --></p>
<script type="text/javascript"> jQuery(document).ready(function($) { window.setTimeout('loadGoogle1_3889()',1000); }); </script><script type="text/javascript"> function loadGoogle1_3889(){ jQuery(document).ready(function($) { $('.dd-google1-3889').remove();$.getScript('https://apis.google.com/js/plusone.js'); }); }</script><!-- Social Buttons Generated by Digg Digg plugin v5.2.6,
    Author : Buffer, Inc
    Website : http://bufferapp.com/diggdigg -->]]></content:encoded>
			<wfw:commentRss>http://lineadecodigo.com/html5/modificando-propiedades-css-con-un-slider/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Menú Contextual en HTML5</title>
		<link>http://lineadecodigo.com/html5/menu-contextual-en-html5/</link>
		<comments>http://lineadecodigo.com/html5/menu-contextual-en-html5/#comments</comments>
		<pubDate>Tue, 14 Feb 2012 20:00:36 +0000</pubDate>
		<dc:creator>Víctor Cuervo</dc:creator>
				<category><![CDATA[HTML5]]></category>
		<category><![CDATA[contextmenu]]></category>
		<category><![CDATA[icon]]></category>
		<category><![CDATA[label]]></category>
		<category><![CDATA[menu]]></category>
		<category><![CDATA[menu contextual]]></category>
		<category><![CDATA[menuitem]]></category>
		<category><![CDATA[section]]></category>

		<guid isPermaLink="false">http://lineadecodigo.com/?p=3835</guid>
		<description><![CDATA[Una de las cosas que no está todavía soportada por los navegadores web respecto al HTML5 son los menús contextuales. A día de hoy solo Firefox 8 y superiores dan soporte al menú contextual en HTML5. Pero, ¿qué es un menú contextual? Un menú contextual es aquel menú asociado a una zona de la página [...]]]></description>
			<content:encoded><![CDATA[<div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><div class='dd-google1-ajax-load dd-google1-3835'></div><g:plusone size='medium' href='http://lineadecodigo.com/html5/menu-contextual-en-html5/'></g:plusone></div><div class='dd_button'><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http%3A%2F%2Flineadecodigo.com%2Fhtml5%2Fmenu-contextual-en-html5%2F" send="false" show_faces="false"  layout="button_count" width="92"  ></fb:like></div><div class='dd_button'><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://lineadecodigo.com/html5/menu-contextual-en-html5/" data-count="horizontal" data-text="Menú Contextual en HTML5" data-via="" ></a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div></div><div style='clear:both'></div></div><div style='clear:both'></div><p>Una de las cosas que no está todavía soportada por los navegadores web respecto al <a title="Tutorial de HTML5" href="http://www.manualweb.net/tutorial-html5/">HTML5</a> son los menús contextuales. A día de hoy solo <a href="http://www.ayudaenlaweb.com/navegadores/que-es-firefox/" title="Qué es Firefox">Firefox 8</a> y superiores dan soporte al menú contextual en <a title="Tutorial de HTML5" href="http://www.manualweb.net/tutorial-html5/">HTML5</a>.</p>
<p>Pero, ¿qué es un menú contextual? Un menú contextual es aquel menú asociado a una zona de la página y el cual tenemos disponible mediante el botón derecho del ratón.</p>
<p>Lo primero de todo será saber cómo se define un menú contextual. Para ello vamos a necesitar el <a href="http://w3api.com/wiki/HTML5:MENU" title="Elemento MENU de HTML5">elemento menú</a>.</p>
<pre class="html4strict" style="font-family:monospace;">&nbsp;
<span style="color: #009900;">&lt;menu <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;colorMenu&quot;</span>&gt;</span>...<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>menu&gt;</span>
&nbsp;</pre>
<p>Lo importante en el caso de estar creando un menú contextual es que el tipo del menú es "context". Otros valores son "toolbar" o "list".</p>
<p>Lo siguiente que haremos será definir los diferentes items o elementos que tendrá el menú. En este caso utilizamos el elemento menuitem para dar de alta cada uno de ellos.</p>
<pre class="html4strict" style="font-family:monospace;">&nbsp;
<span style="color: #009900;">&lt;menu <a href="http://w3api.com/wiki/HTML:type"><span style="color: #000066;">type</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;context&quot;</span> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;colorMenu&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;menuitem <a href="http://w3api.com/wiki/HTML:label"><span style="color: #000066;">label</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Rojo&quot;</span> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;rojo&quot;</span> icon<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;rojo.png&quot;</span><span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #66cc66;">/</span>menuitem&gt;</span>
<span style="color: #009900;">&lt;menuitem <a href="http://w3api.com/wiki/HTML:label"><span style="color: #000066;">label</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Verde&quot;</span> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;verde&quot;</span> icon<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;verde.png&quot;</span><span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #66cc66;">/</span>menuitem&gt;</span>
<span style="color: #009900;">&lt;menuitem <a href="http://w3api.com/wiki/HTML:label"><span style="color: #000066;">label</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Azul&quot;</span> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;azul&quot;</span> icon<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;azul.png&quot;</span><span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #66cc66;">/</span>menuitem&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>menu&gt;</span>
&nbsp;</pre>
<p>Vemos que cada menuitem lleva asociado un atributo label, que será el texto que aparezca en la opción del menú, un id y un icono, el cual definimos mediante el atributo icon. Ya solo nos quedará decidir dónde se va a lanzar el menú. Sobre que parte de la página se podrá ver este menú contextual en <a title="Tutorial de HTML5" href="http://www.manualweb.net/tutorial-html5/">HTML5</a>. Para ello utilizamos el atributo general contextmenu, al cual deberemos de pasar el ID del menú que acabamos de crear. Que queremos aplicar el menú sobre una sección de la página escribiremos:</p>
<pre class="html4strict" style="font-family:monospace;">&nbsp;
<span style="color: #009900;">&lt;section contextmenu<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;colorMenu&quot;</span> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;miseccion&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>section&gt;</span>
&nbsp;</pre>
<p>Que lo queremos aplicar sobre un <a href="http://w3api.com/wiki/HTML5:INPUT" title="Elemento INPUT de HTML5">campo de input</a>, pues escribirmos lo siguiente:</p>
<pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:LABEL"><span style="color: #000000; font-weight: bold;">label</span></a> <a href="http://w3api.com/wiki/HTML:for"><span style="color: #000066;">for</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;color&quot;</span>&gt;</span>Color:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:LABEL"><span style="color: #000000; font-weight: bold;">label</span></a>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:INPUT"><span style="color: #000000; font-weight: bold;">input</span></a> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;color&quot;</span> <a href="http://w3api.com/wiki/HTML:type"><span style="color: #000066;">type</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> contextmenu<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;colorMenu&quot;</span>&gt;</span>
&nbsp;</pre>
<p>Ya solo nos quedará pulsar con el botón derecho sobre la zona del menú contextual para ver el efecto.</p>
<p><a href="http://img.aulambra.com/wp-content/uploads/2012/02/contextmenu.png"><img src="http://img.aulambra.com/wp-content/uploads/2012/02/contextmenu.png" alt="" title="contextmenu" width="500" height="372" class="aligncenter size-full wp-image-3840" /></a></p>
<p>Sobre los menús contextuales podemos manejar los eventos como sobre cualquier otro elemento de la página. Así podemos añadir el siguiente código en <a href="http://www.manualweb.net/tutorial-javascript/" title="Manual de Javascript">Javascript</a> para controlar el click sobre las opciones del menú contextual.</p>
<pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> campo <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;color&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> color <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;colorMenu&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
color.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;click&quot;</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>ev<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	campo.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> ev.<span style="color: #660066;">target</span>.<span style="color: #660066;">label</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
<p><strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://lineadecodigo.com/javascript/cambiar-estilos-dinamicamente/" rel="bookmark" title="Septiembre 12, 2009">Cambiar estilos dinámicamente</a></li>
<li><a href="http://lineadecodigo.com/jquery/seleccionar-el-texto-de-un-campo/" rel="bookmark" title="Septiembre 21, 2011">Seleccionar el texto de un campo</a></li>
<li><a href="http://lineadecodigo.com/javascript/hacer-foco-en-un-campo-de-la-pagina-usando-javascript/" rel="bookmark" title="Junio 13, 2007">Hacer foco en un campo de la página usando JavaScript</a></li>
<li><a href="http://lineadecodigo.com/html5/datalist-en-html5/" rel="bookmark" title="Febrero 1, 2012">DataList en HTML5</a></li>
<li><a href="http://lineadecodigo.com/html5/activar-el-corrector-ortografico-con-html5/" rel="bookmark" title="Marzo 6, 2012">Activar el corrector ortográfico con HTML5</a></li>
</ul>
<p><!-- Similar Posts took 5.424 ms --></p>
<script type="text/javascript"> jQuery(document).ready(function($) { window.setTimeout('loadGoogle1_3835()',1000); }); </script><script type="text/javascript"> function loadGoogle1_3835(){ jQuery(document).ready(function($) { $('.dd-google1-3835').remove();$.getScript('https://apis.google.com/js/plusone.js'); }); }</script><!-- Social Buttons Generated by Digg Digg plugin v5.2.6,
    Author : Buffer, Inc
    Website : http://bufferapp.com/diggdigg -->]]></content:encoded>
			<wfw:commentRss>http://lineadecodigo.com/html5/menu-contextual-en-html5/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Crear un Canvas en HTML5</title>
		<link>http://lineadecodigo.com/html5/crear-un-canvas-en-html5/</link>
		<comments>http://lineadecodigo.com/html5/crear-un-canvas-en-html5/#comments</comments>
		<pubDate>Tue, 07 Feb 2012 07:00:08 +0000</pubDate>
		<dc:creator>Víctor Cuervo</dc:creator>
				<category><![CDATA[HTML5]]></category>
		<category><![CDATA[2d]]></category>
		<category><![CDATA[3d]]></category>
		<category><![CDATA[Canvas]]></category>
		<category><![CDATA[CanvasRenderingContext2D]]></category>
		<category><![CDATA[fillRect]]></category>
		<category><![CDATA[fillStyle]]></category>
		<category><![CDATA[getContext]]></category>
		<category><![CDATA[getElementById]]></category>
		<category><![CDATA[height]]></category>
		<category><![CDATA[id]]></category>
		<category><![CDATA[width]]></category>

		<guid isPermaLink="false">http://lineadecodigo.com/?p=3829</guid>
		<description><![CDATA[El canvas es un elemento que aparece nuevo en HTML5 y que nos permitirá la gestión de gráficos. Así podremos dibujar gráficos, crear foto composiciones, realizar animaciones,... Para crear un canvas en HTML5 tenemos que utilizar el elemento CANVAS. &#60;canvas&#62; Contenido alternativo &#60;/canvas&#62; A un elemento CANVAS podemos darle un alto y ancho mediante los [...]]]></description>
			<content:encoded><![CDATA[<div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><div class='dd-google1-ajax-load dd-google1-3829'></div><g:plusone size='medium' href='http://lineadecodigo.com/html5/crear-un-canvas-en-html5/'></g:plusone></div><div class='dd_button'><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http%3A%2F%2Flineadecodigo.com%2Fhtml5%2Fcrear-un-canvas-en-html5%2F" send="false" show_faces="false"  layout="button_count" width="92"  ></fb:like></div><div class='dd_button'><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://lineadecodigo.com/html5/crear-un-canvas-en-html5/" data-count="horizontal" data-text="Crear un Canvas en HTML5" data-via="" ></a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div></div><div style='clear:both'></div></div><div style='clear:both'></div><p>El canvas es un elemento que aparece nuevo en <a href="http://www.manualweb.net/tutorial-html5/" title="Manual de HTML5">HTML5</a> y que nos permitirá la gestión de gráficos. Así podremos dibujar gráficos, crear foto composiciones, realizar animaciones,...</p>
<p>Para crear un canvas en <a href="http://www.manualweb.net/tutorial-html5/" title="Manual de HTML5">HTML5</a> tenemos que utilizar el elemento <a href="http://www.w3api.com/wiki/HTML5:CANVAS" title="Elemento CANVAS de HTML5">CANVAS</a>.</p>
<pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;canvas&gt;</span>
  Contenido alternativo
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>canvas&gt;</span></pre>
<p>A un elemento <a href="http://www.w3api.com/wiki/HTML5:CANVAS" title="Elemento CANVAS de HTML5">CANVAS</a> podemos darle un alto y ancho mediante los atributos <a href="http://www.w3api.com/wiki/HTML5:CANVAS.height" title="Atributo height del CANVAS">height</a> y <a href="http://www.w3api.com/wiki/HTML5:CANVAS.width" title="Atributo width del CANVAS">width</a> respectivamente. Así como darle un identificador mediante el <a href="http://www.w3api.com/wiki/HTML5:Id" title="Atributo id de HTML5">atributo id</a>.</p>
<pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;canvas <a href="http://w3api.com/wiki/HTML:height"><span style="color: #000066;">height</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;300px&quot;</span> <a href="http://w3api.com/wiki/HTML:width"><span style="color: #000066;">width</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;300px&quot;</span> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;micanvas&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span>canvas&gt;</span></pre>
<p>En el caso de que no indiquemos las dimesiones, estas serán de 300x150.</p>
<p>Una vez que tenemos nuestro "lienzo" vamos a dibujar algún gráfico. Para ello utilizaremos el lenguaje <a href="http://www.manualweb.net/tutorial-javascript/" title="Tutorial de Javascript">Javascript</a>. Así lo primero que haremos será obtener la referencia sobre el <a href="http://www.w3api.com/wiki/HTML5:CANVAS" title="Elemento CANVAS de HTML5">CANVAS</a> mediante un <a href="http://www.w3api.com/wiki/DOM:Document.getElementById()" title="Método .getElementById del DOM">getElementById()</a>.</p>
<pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> canvas <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;micanvas&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
<p>Dentro de un <a href="http://www.w3api.com/wiki/HTML5:CANVAS" title="Elemento CANVAS de HTML5">CANVAS</a> podemos volcar varios contextos. Lo que son conocidos como contextos de renderizado. Así podremos tener contextos 2D y 3D. Estos últimos todavía en fase experimental. El método <a href="http://www.w3api.com/wiki/DOM:HTMLCanvasElement.getContext()" title="Método .getContext() del CANVAS">.getContext()</a> sobre el <a href="http://www.w3api.com/wiki/HTML5:CANVAS" title="Elemento CANVAS de HTML5">CANVAS</a> nos permitirá crear un nuevo contexto.</p>
<pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> canvas <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;micanvas&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> ctx <span style="color: #339933;">=</span> canvas.<span style="color: #660066;">getContext</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;2d&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
<p>Ahora ya pasaremos a dibujar gráficos. Así, con el manejo de una propiedad: <a href="http://www.w3api.com/wiki/DOM:CanvasRenderingContext2D.fillStyle" title="Atributo fillStyle del Contexto del CANVAS">.fillStyle</a> y un método <a href="http://www.w3api.com/wiki/DOM:CanvasRenderingContext2D.fillRect()" title="Método fillRect sobre un contexto del CANVAS">.fillRect()</a> podemos crear rectángulos de colores. En el caso de <a href="http://www.w3api.com/wiki/DOM:CanvasRenderingContext2D.fillStyle" title="Atributo fillStyle del Contexto del CANVAS">.fillStyle</a> recibe como parámetro un color definido en formato RGB y en el caso de  <a href="http://www.w3api.com/wiki/DOM:CanvasRenderingContext2D.fillRect()" title="Método fillRect sobre un contexto del CANVAS">.fillRect()</a> las coordenadas de los vertices superior izquierdo, así como el alto y ancho.</p>
<p>Así nos quedará el código que insertará gráficos al crear nuestro primer canvas con <a href="http://www.manualweb.net/tutorial-html5/" title="Manual de HTML5">HTML5</a>.</p>
<pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> canvas <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;micanvas&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> ctx <span style="color: #339933;">=</span> canvas.<span style="color: #660066;">getContext</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;2d&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
ctx.<span style="color: #660066;">fillStyle</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;rgb(255,0,0)&quot;</span><span style="color: #339933;">;</span>
ctx.<span style="color: #660066;">fillRect</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">20</span><span style="color: #339933;">,</span><span style="color: #CC0000;">20</span><span style="color: #339933;">,</span><span style="color: #CC0000;">100</span><span style="color: #339933;">,</span><span style="color: #CC0000;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
ctx.<span style="color: #660066;">fillStyle</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;rgb(0,255,0)&quot;</span><span style="color: #339933;">;</span>
ctx.<span style="color: #660066;">fillRect</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">60</span><span style="color: #339933;">,</span><span style="color: #CC0000;">60</span><span style="color: #339933;">,</span><span style="color: #CC0000;">140</span><span style="color: #339933;">,</span><span style="color: #CC0000;">140</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
ctx.<span style="color: #660066;">fillStyle</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;rgb(0,0,255)&quot;</span><span style="color: #339933;">;</span>
ctx.<span style="color: #660066;">fillRect</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">100</span><span style="color: #339933;">,</span><span style="color: #CC0000;">100</span><span style="color: #339933;">,</span><span style="color: #CC0000;">180</span><span style="color: #339933;">,</span><span style="color: #CC0000;">180</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
<p><strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://lineadecodigo.com/javascript/documentgetelementbyid/" rel="bookmark" title="Junio 25, 2007">document.getElementById</a></li>
<li><a href="http://lineadecodigo.com/javascript/modernizr-y-las-capacidades-html5-y-css3/" rel="bookmark" title="Enero 3, 2012">Modernizr y las capacidades HTML5 y CSS3</a></li>
<li><a href="http://lineadecodigo.com/html5/parar-la-descarga-de-un-video-en-html5/" rel="bookmark" title="Enero 21, 2012">Parar la descarga de un vídeo en HTML5</a></li>
<li><a href="http://lineadecodigo.com/svg/dibujar-una-elipse-en-svg/" rel="bookmark" title="Enero 11, 2008">Dibujar una elipse en SVG</a></li>
<li><a href="http://lineadecodigo.com/javascript/cambiar-el-tamano-de-la-imagen-de-forma-dinamica/" rel="bookmark" title="Enero 12, 2007">Cambiar el tamaño de la imagen de forma dinamica</a></li>
</ul>
<p><!-- Similar Posts took 8.830 ms --></p>
<script type="text/javascript"> jQuery(document).ready(function($) { window.setTimeout('loadGoogle1_3829()',1000); }); </script><script type="text/javascript"> function loadGoogle1_3829(){ jQuery(document).ready(function($) { $('.dd-google1-3829').remove();$.getScript('https://apis.google.com/js/plusone.js'); }); }</script><!-- Social Buttons Generated by Digg Digg plugin v5.2.6,
    Author : Buffer, Inc
    Website : http://bufferapp.com/diggdigg -->]]></content:encoded>
			<wfw:commentRss>http://lineadecodigo.com/html5/crear-un-canvas-en-html5/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Tiempo visualizado del vídeo en HTML5</title>
		<link>http://lineadecodigo.com/html5/tiempo-visualizado-del-video-en-html5/</link>
		<comments>http://lineadecodigo.com/html5/tiempo-visualizado-del-video-en-html5/#comments</comments>
		<pubDate>Mon, 06 Feb 2012 07:00:11 +0000</pubDate>
		<dc:creator>Víctor Cuervo</dc:creator>
				<category><![CDATA[HTML5]]></category>
		<category><![CDATA[addEventListener]]></category>
		<category><![CDATA[currentTime]]></category>
		<category><![CDATA[segundos]]></category>
		<category><![CDATA[timeupdate]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://lineadecodigo.com/?p=3823</guid>
		<description><![CDATA[Seguimos con el análisis del manejo de vídeos en HTML5, así como con el manejo del elemento DOM HTMLMediaElement. En este caso vamos a ver como podemos ir viendo el tiempo visualizado del vídeo en HTML5. Es decir, según vaya avanzando la visualización del vídeo, calcular los segundos que hayan transcurrido de la visualización. Lo [...]]]></description>
			<content:encoded><![CDATA[<div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><div class='dd-google1-ajax-load dd-google1-3823'></div><g:plusone size='medium' href='http://lineadecodigo.com/html5/tiempo-visualizado-del-video-en-html5/'></g:plusone></div><div class='dd_button'><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http%3A%2F%2Flineadecodigo.com%2Fhtml5%2Ftiempo-visualizado-del-video-en-html5%2F" send="false" show_faces="false"  layout="button_count" width="92"  ></fb:like></div><div class='dd_button'><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://lineadecodigo.com/html5/tiempo-visualizado-del-video-en-html5/" data-count="horizontal" data-text="Tiempo visualizado del vídeo en HTML5" data-via="" ></a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div></div><div style='clear:both'></div></div><div style='clear:both'></div><p>Seguimos con el análisis del manejo de vídeos en <a href="http://www.manualweb.net/tutorial-html5/" title="Manual de HTML5">HTML5</a>, así como con el manejo del <a href="http://www.w3api.com/wiki/DOM:HTMLMediaElement" title="Elemento del DOM HTMLMediaElement">elemento DOM HTMLMediaElement</a>. En este caso vamos a ver como podemos ir viendo el tiempo visualizado del vídeo en <a href="http://www.manualweb.net/tutorial-html5/" title="Manual de HTML5">HTML5</a>. Es decir, según vaya avanzando la visualización del vídeo, calcular los segundos que hayan transcurrido de la visualización.</p>
<p>Lo primero será poner el vídeo en nuestra página web.</p>
<pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;video <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;mivideo&quot;</span> controls&gt;</span>
  <span style="color: #009900;">&lt;source <a href="http://w3api.com/wiki/HTML:src"><span style="color: #000066;">src</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://easyhtml5video.com/images/happyfit2.ogv&quot;</span> <a href="http://w3api.com/wiki/HTML:type"><span style="color: #000066;">type</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;video/ogg&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span>source&gt;</span>
  Tu navegador no soporta el elemento <span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:CODE"><span style="color: #000000; font-weight: bold;">code</span></a>&gt;</span>video<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:CODE"><span style="color: #000000; font-weight: bold;">code</span></a>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>video&gt;</span></pre>
<p>Cuándo el usuario pulse al play se irán sucediendo una serie de eventos. Uno de los eventos importantes es <a href="http://www.w3api.com/wiki/DOM:HTMLMediaElement.ontimeupdate" title="Evento timeupdate del elemento HTMLMediaElement">timeupdate</a>. Dicho evento se envía progresivamente según avanza la visualización del vídeo. Así que tendremos que crear un listener sobre dicho evento en el vídeo.</p>
<pre class="javascript" style="font-family:monospace;"> <span style="color: #003366; font-weight: bold;">var</span> v <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;mivideo&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 v.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;timeupdate&quot;</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>ev<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  ...
 <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
<p>Cuándo se ejecute el método asociado al listener deberemos de acceder al atributo <a href="http://www.w3api.com/wiki/DOM:HTMLMediaElement.currentTime" title="Atributo currentTime del elemento HTMLMediaElement">.currentTime</a> del <a href="http://www.w3api.com/wiki/DOM:HTMLMediaElement" title="Elemento del DOM HTMLMediaElement">HTMLMediaElement</a>, ya que este atributo es el que contiene el tiempo transcurrido del vídeo. Este tiempo será en segundos.</p>
<p>Lo que nosotros hacemos es volcar el contenido del atributo  <a href="http://www.w3api.com/wiki/DOM:HTMLMediaElement.currentTime" title="Atributo currentTime del elemento HTMLMediaElement">.currentTime</a> sobre una capa. Este contenido se irá actualizando cada vez que se lance el evento <a href="http://www.w3api.com/wiki/DOM:HTMLMediaElement.ontimeupdate" title="Evento timeupdate del elemento HTMLMediaElement">timeupdate</a> en el vídeo.</p>
<pre class="javascript" style="font-family:monospace;">v.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;timeupdate&quot;</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>ev<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
   document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;tiemposegundos&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> v.<span style="color: #660066;">currentTime</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
<p>Si queremos "dejarlo bonito" podemos convertir el tiempo en segundos en un formato reloj, igual que explicábamos en el artículo <a href="http://lineadecodigo.com/javascript/convertir-segundos-en-formato-hora-con-javascript/" title="Convertir segundos en formato hora con Javascript">Convertir segundos en formato hora con Javascript</a>.</p>
<p>Nosotros hemos metido este código dentro de una función que la hemos llamado hora, la cual recibe una cantidad de segundos, los cuales los devuelve en un formato hh:mm:ss.</p>
<pre class="javascript" style="font-family:monospace;"> <span style="color: #003366; font-weight: bold;">function</span> hora<span style="color: #009900;">&#40;</span>segundos<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> d<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span>segundos<span style="color: #339933;">*</span><span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #006600; font-style: italic;">// Ajuste de las 23 horas</span>
  <span style="color: #003366; font-weight: bold;">var</span> hora <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>d.<span style="color: #660066;">getHours</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span><span style="color: #CC0000;">23</span><span style="color: #339933;">:</span>d.<span style="color: #660066;">getHours</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> hora <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>hora<span style="color: #339933;">&lt;</span><span style="color: #CC0000;">9</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span><span style="color: #3366CC;">&quot;0&quot;</span><span style="color: #339933;">+</span>hora<span style="color: #339933;">:</span>hora<span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> minuto <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>d.<span style="color: #660066;">getMinutes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&lt;</span><span style="color: #CC0000;">9</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span><span style="color: #3366CC;">&quot;0&quot;</span><span style="color: #339933;">+</span>d.<span style="color: #660066;">getMinutes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span>d.<span style="color: #660066;">getMinutes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> segundo <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>d.<span style="color: #660066;">getSeconds</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&lt;</span><span style="color: #CC0000;">9</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span><span style="color: #3366CC;">&quot;0&quot;</span><span style="color: #339933;">+</span>d.<span style="color: #660066;">getSeconds</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span>d.<span style="color: #660066;">getSeconds</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">return</span> hora<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;:&quot;</span><span style="color: #339933;">+</span>minuto<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;:&quot;</span><span style="color: #339933;">+</span>segundo<span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span></pre>
<p>Ya solo nos quedará invocar a esta función desde el listener:</p>
<pre class="javascript" style="font-family:monospace;">v.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;timeupdate&quot;</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>ev<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
   document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;tiemposegundos&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> v.<span style="color: #660066;">currentTime</span><span style="color: #339933;">;</span>
   document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;tiempo&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> hora<span style="color: #009900;">&#40;</span>v.<span style="color: #660066;">currentTime</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
<p><strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://lineadecodigo.com/html5/tiempo-total-de-un-video-html5/" rel="bookmark" title="Febrero 2, 2012">Tiempo total de un vídeo HTML5</a></li>
<li><a href="http://lineadecodigo.com/javascript/convertir-segundos-en-formato-hora-con-javascript/" rel="bookmark" title="Enero 23, 2012">Convertir segundos en formato hora con Javascript</a></li>
<li><a href="http://lineadecodigo.com/javascript/convertir-una-cadena-a-fecha-en-javascript/" rel="bookmark" title="Enero 29, 2012">Convertir una cadena a fecha en Javascript</a></li>
<li><a href="http://lineadecodigo.com/html5/elemento-rango-en-formularios-html5/" rel="bookmark" title="Enero 31, 2012">Elemento rango en formularios HTML5</a></li>
<li><a href="http://lineadecodigo.com/html5/activar-el-corrector-ortografico-con-html5/" rel="bookmark" title="Marzo 6, 2012">Activar el corrector ortográfico con HTML5</a></li>
</ul>
<p><!-- Similar Posts took 8.692 ms --></p>
<script type="text/javascript"> jQuery(document).ready(function($) { window.setTimeout('loadGoogle1_3823()',1000); }); </script><script type="text/javascript"> function loadGoogle1_3823(){ jQuery(document).ready(function($) { $('.dd-google1-3823').remove();$.getScript('https://apis.google.com/js/plusone.js'); }); }</script><!-- Social Buttons Generated by Digg Digg plugin v5.2.6,
    Author : Buffer, Inc
    Website : http://bufferapp.com/diggdigg -->]]></content:encoded>
			<wfw:commentRss>http://lineadecodigo.com/html5/tiempo-visualizado-del-video-en-html5/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
<enclosure url="http://easyhtml5video.com/images/happyfit2.ogv" length="10220659" type="video/ogg" />
		</item>
		<item>
		<title>Autofoco a un campo con HTML5</title>
		<link>http://lineadecodigo.com/html5/autofoco-a-un-campo-con-html5/</link>
		<comments>http://lineadecodigo.com/html5/autofoco-a-un-campo-con-html5/#comments</comments>
		<pubDate>Sun, 05 Feb 2012 15:00:08 +0000</pubDate>
		<dc:creator>Víctor Cuervo</dc:creator>
				<category><![CDATA[HTML5]]></category>
		<category><![CDATA[autofocus]]></category>
		<category><![CDATA[focus]]></category>
		<category><![CDATA[Form]]></category>
		<category><![CDATA[input]]></category>

		<guid isPermaLink="false">http://lineadecodigo.com/?p=3814</guid>
		<description><![CDATA[Antes de tener la especificación de HTML5 si queríamos realizar un autofoco a un campo, es decir, que al cargar una página el foco del cursor se pusiese en un campo de un formulario, teníamos que utilizar código Javascript. Ahora, gracias a HTML5, podemos acometer esta labor de una forma sencilla. Lo primero será definir [...]]]></description>
			<content:encoded><![CDATA[<div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><div class='dd-google1-ajax-load dd-google1-3814'></div><g:plusone size='medium' href='http://lineadecodigo.com/html5/autofoco-a-un-campo-con-html5/'></g:plusone></div><div class='dd_button'><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http%3A%2F%2Flineadecodigo.com%2Fhtml5%2Fautofoco-a-un-campo-con-html5%2F" send="false" show_faces="false"  layout="button_count" width="92"  ></fb:like></div><div class='dd_button'><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://lineadecodigo.com/html5/autofoco-a-un-campo-con-html5/" data-count="horizontal" data-text="Autofoco a un campo con HTML5" data-via="" ></a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div></div><div style='clear:both'></div></div><div style='clear:both'></div><p>Antes de tener la especificación de <a title="Manual de HTML5" href="http://www.manualweb.net/tutorial-html5/">HTML5</a> si queríamos realizar un autofoco a un campo, es decir, que al cargar una página el foco del cursor se pusiese en un campo de un formulario, <a title="Usar focus() en Javascript" href="http://lineadecodigo.com/javascript/hacer-foco-en-un-campo-de-la-pagina-usando-javascript/">teníamos que utilizar código Javascript</a>.<br />
Ahora, gracias a <a title="Manual de HTML5" href="http://www.manualweb.net/tutorial-html5/">HTML5</a>, podemos acometer esta labor de una forma sencilla.</p>
<p>Lo primero será definir el formulario. En nuestro caso tendrá dos simples campos de entrada de texto:</p>
<pre class="html4strict" style="font-family:monospace;">&nbsp;
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:FORM"><span style="color: #000000; font-weight: bold;">form</span></a>&gt;</span>
  <span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:LABEL"><span style="color: #000000; font-weight: bold;">label</span></a> <a href="http://w3api.com/wiki/HTML:for"><span style="color: #000066;">for</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nombre&quot;</span>&gt;</span>¿Cómo te llamas?<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:LABEL"><span style="color: #000000; font-weight: bold;">label</span></a>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:INPUT"><span style="color: #000000; font-weight: bold;">input</span></a> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nombre&quot;</span> <a href="http://w3api.com/wiki/HTML:type"><span style="color: #000066;">type</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
  <span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:LABEL"><span style="color: #000000; font-weight: bold;">label</span></a> <a href="http://w3api.com/wiki/HTML:for"><span style="color: #000066;">for</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;edad&quot;</span>&gt;</span>¿Cuántos años tienes?<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:LABEL"><span style="color: #000000; font-weight: bold;">label</span></a>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:INPUT"><span style="color: #000000; font-weight: bold;">input</span></a> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;edad&quot;</span> <a href="http://w3api.com/wiki/HTML:type"><span style="color: #000066;">type</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:FORM"><span style="color: #000000; font-weight: bold;">form</span></a>&gt;</span>
&nbsp;</pre>
<p>Si lo que queremos es que el autofoco se realice sobre el campo <a title="Elemento INPUT de HTML5" href="http://www.w3api.com/wiki/HTML5:INPUT">INPUT</a> nombre, le añadiremos el atributo <a title="Atributo autofocus del elemento INPUT" href="http://www.w3api.com/wiki/HTML5:INPUT.autofocus">autofocus</a>. Quedándonos el siguiente código:</p>
<pre class="html4strict" style="font-family:monospace;">&nbsp;
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:FORM"><span style="color: #000000; font-weight: bold;">form</span></a>&gt;</span>
  <span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:LABEL"><span style="color: #000000; font-weight: bold;">label</span></a> <a href="http://w3api.com/wiki/HTML:for"><span style="color: #000066;">for</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nombre&quot;</span>&gt;</span>¿Cómo te llamas?<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:LABEL"><span style="color: #000000; font-weight: bold;">label</span></a>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:INPUT"><span style="color: #000000; font-weight: bold;">input</span></a> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nombre&quot;</span> autofoucs <a href="http://w3api.com/wiki/HTML:type"><span style="color: #000066;">type</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
  <span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:LABEL"><span style="color: #000000; font-weight: bold;">label</span></a> <a href="http://w3api.com/wiki/HTML:for"><span style="color: #000066;">for</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;edad&quot;</span>&gt;</span>¿Cuántos años tienes?<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:LABEL"><span style="color: #000000; font-weight: bold;">label</span></a>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:INPUT"><span style="color: #000000; font-weight: bold;">input</span></a> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;edad&quot;</span> <a href="http://w3api.com/wiki/HTML:type"><span style="color: #000066;">type</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:FORM"><span style="color: #000000; font-weight: bold;">form</span></a>&gt;</span>
&nbsp;</pre>
<blockquote><p>El atributo <a title="Atributo autofocus del elemento INPUT" href="http://www.w3api.com/wiki/HTML5:INPUT.autofocus">autofocus</a> solo puede aplicarse sobre un único campo del formulario</p></blockquote>
<p>Solo tenemos que tener cuidado de una cosa y es que la especificación <a title="Manual de HTML5" href="http://www.manualweb.net/tutorial-html5/">HTML5</a> todavía no está terminada ni implementada en todos los navegadores web. Es por ello que puede ser que no funcione correctamente. Las versiones mínimas en las que funciona son <a title="Qué es Google Chrome" href="http://www.ayudaenlaweb.com/navegadores/que-es-google-chrome/">Chrome</a> 6, <a title="Qué es Firefox" href="http://www.ayudaenlaweb.com/navegadores/que-es-firefox/">Firefox</a> 4, <a title="Qué es Opera" href="http://www.ayudaenlaweb.com/navegadores/que-es-opera/">Opera</a> 11, <a title="Qué es Safari" href="http://www.ayudaenlaweb.com/navegadores/que-es-safari/">Safari</a> 5 e <a title="Qué es el Internet Explorer" href="http://www.ayudaenlaweb.com/navegadores/que-es-internet-explorer/">Internet Explorer</a> 10. Quizás la versión del <a title="Qué es el Internet Explorer" href="http://www.ayudaenlaweb.com/navegadores/que-es-internet-explorer/">Internet Explorer</a> sea la que más problemas pueda ocasionarte.</p>
<p>En este caso podemos recurrir a la implementación en <a title="Manual de Javascript" href="http://www.manualweb.net/tutorial-javascript/">Javascript</a>. En este caso vamos a crear mediante <a title="Manual de Javascript" href="http://www.manualweb.net/tutorial-javascript/">Javascript</a> un elemento <a title="Elemento INPUT de HTML5" href="http://www.w3api.com/wiki/HTML5:INPUT">INPUT</a> ficiticio y vamos a comprobar si este tiene el atributo autofocus o no. En caso de que no lo tenga lanzaremos el código <a title="Manual de Javascript" href="http://www.manualweb.net/tutorial-javascript/">Javascript</a> con el método <a title="Método focus() de Javascript" href="http://www.w3api.com/wiki/DOM:Element.focus()">.focus()</a></p>
<pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;autofocus&quot;</span> <span style="color: #000066; font-weight: bold;">in</span> document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;input&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
  document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;nombre&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">focus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
<p><strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://lineadecodigo.com/javascript/hacer-foco-en-un-campo-de-la-pagina-usando-javascript/" rel="bookmark" title="Junio 13, 2007">Hacer foco en un campo de la página usando JavaScript</a></li>
<li><a href="http://lineadecodigo.com/jquery/seleccionar-texto-al-posicionarse-en-un-campo/" rel="bookmark" title="Septiembre 23, 2011">Seleccionar texto al posicionarse en un campo</a></li>
<li><a href="http://lineadecodigo.com/javascript/cambiar-el-valor-de-un-radio-group-dinamicamente/" rel="bookmark" title="Septiembre 19, 2009">Cambiar el valor de un radio group dinámicamente</a></li>
<li><a href="http://lineadecodigo.com/jquery/seleccionar-un-texto-solo-si-no-ha-cambiado/" rel="bookmark" title="Octubre 11, 2011">Seleccionar un texto solo si no ha cambiado</a></li>
<li><a href="http://lineadecodigo.com/html5/placeholder-marcadores-de-posicion-en-html5/" rel="bookmark" title="Enero 12, 2011">PlaceHolder: Marcadores de posición en HTML5</a></li>
</ul>
<p><!-- Similar Posts took 8.759 ms --></p>
<script type="text/javascript"> jQuery(document).ready(function($) { window.setTimeout('loadGoogle1_3814()',1000); }); </script><script type="text/javascript"> function loadGoogle1_3814(){ jQuery(document).ready(function($) { $('.dd-google1-3814').remove();$.getScript('https://apis.google.com/js/plusone.js'); }); }</script><!-- Social Buttons Generated by Digg Digg plugin v5.2.6,
    Author : Buffer, Inc
    Website : http://bufferapp.com/diggdigg -->]]></content:encoded>
			<wfw:commentRss>http://lineadecodigo.com/html5/autofoco-a-un-campo-con-html5/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Served from: lineadecodigo.com @ 2012-05-17 19:58:55 by W3 Total Cache -->
