<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"> <channel><title>Linea de Codigo</title> <link>http://lineadecodigo.com</link> <description>/* Programación en la red */</description> <lastBuildDate>Tue, 07 Feb 2012 07:00:08 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/LineaDeCodigo" /><feedburner:info uri="lineadecodigo" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item><title>Crear un Canvas en HTML5</title><link>http://feedproxy.google.com/~r/LineaDeCodigo/~3/Lp7PuEgOs_M/</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[<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/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/javascript/documentgetelementbyid/" rel="bookmark" title="Junio 25, 2007">document.getElementById</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/crear-elementos-html-con-javascript/" rel="bookmark" title="Septiembre 9, 2007">Crear elementos HTML con JavaScript</a></li></ul><p></p> 
<p><a href="http://feedads.g.doubleclick.net/~a/Ofrepk9WUt6EBK9XSbBQ26u1fIM/0/da"><img src="http://feedads.g.doubleclick.net/~a/Ofrepk9WUt6EBK9XSbBQ26u1fIM/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Ofrepk9WUt6EBK9XSbBQ26u1fIM/1/da"><img src="http://feedads.g.doubleclick.net/~a/Ofrepk9WUt6EBK9XSbBQ26u1fIM/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=Lp7PuEgOs_M:PNLCa0xix8g:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=Lp7PuEgOs_M:PNLCa0xix8g:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?i=Lp7PuEgOs_M:PNLCa0xix8g:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=Lp7PuEgOs_M:PNLCa0xix8g:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?i=Lp7PuEgOs_M:PNLCa0xix8g:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=Lp7PuEgOs_M:PNLCa0xix8g:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=Lp7PuEgOs_M:PNLCa0xix8g:tKBiNdHYW3c"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?d=tKBiNdHYW3c" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LineaDeCodigo/~4/Lp7PuEgOs_M" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://lineadecodigo.com/html5/crear-un-canvas-en-html5/feed/</wfw:commentRss> <slash:comments>1</slash:comments> <feedburner:origLink>http://lineadecodigo.com/html5/crear-un-canvas-en-html5/</feedburner:origLink></item> <item><title>Tiempo visualizado del vídeo en HTML5</title><link>http://feedproxy.google.com/~r/LineaDeCodigo/~3/1f-4Ei1lEDo/</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[<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/javascript/crear-eventos-con-javascript/" rel="bookmark" title="Septiembre 29, 2007">Crear eventos con JavaScript</a></li></ul><p></p> 
<p><a href="http://feedads.g.doubleclick.net/~a/dfnPkE5kGHcfZIx5YRAkMLeiSss/0/da"><img src="http://feedads.g.doubleclick.net/~a/dfnPkE5kGHcfZIx5YRAkMLeiSss/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/dfnPkE5kGHcfZIx5YRAkMLeiSss/1/da"><img src="http://feedads.g.doubleclick.net/~a/dfnPkE5kGHcfZIx5YRAkMLeiSss/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=1f-4Ei1lEDo:nJbHVpTADEk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=1f-4Ei1lEDo:nJbHVpTADEk:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?i=1f-4Ei1lEDo:nJbHVpTADEk:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=1f-4Ei1lEDo:nJbHVpTADEk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?i=1f-4Ei1lEDo:nJbHVpTADEk:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=1f-4Ei1lEDo:nJbHVpTADEk:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=1f-4Ei1lEDo:nJbHVpTADEk:tKBiNdHYW3c"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?d=tKBiNdHYW3c" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LineaDeCodigo/~4/1f-4Ei1lEDo" height="1" width="1"/>]]></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" /> <feedburner:origLink>http://lineadecodigo.com/html5/tiempo-visualizado-del-video-en-html5/</feedburner:origLink></item> <item><title>Autofoco a un campo con HTML5</title><link>http://feedproxy.google.com/~r/LineaDeCodigo/~3/3bo-Qlv0Mrs/</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[<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></p> 
<p><a href="http://feedads.g.doubleclick.net/~a/zQMFw2ds_sLgYJkPv9rOaUjqBE8/0/da"><img src="http://feedads.g.doubleclick.net/~a/zQMFw2ds_sLgYJkPv9rOaUjqBE8/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/zQMFw2ds_sLgYJkPv9rOaUjqBE8/1/da"><img src="http://feedads.g.doubleclick.net/~a/zQMFw2ds_sLgYJkPv9rOaUjqBE8/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=3bo-Qlv0Mrs:5X64VmeNifY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=3bo-Qlv0Mrs:5X64VmeNifY:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?i=3bo-Qlv0Mrs:5X64VmeNifY:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=3bo-Qlv0Mrs:5X64VmeNifY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?i=3bo-Qlv0Mrs:5X64VmeNifY:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=3bo-Qlv0Mrs:5X64VmeNifY:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=3bo-Qlv0Mrs:5X64VmeNifY:tKBiNdHYW3c"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?d=tKBiNdHYW3c" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LineaDeCodigo/~4/3bo-Qlv0Mrs" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://lineadecodigo.com/html5/autofoco-a-un-campo-con-html5/feed/</wfw:commentRss> <slash:comments>2</slash:comments> <feedburner:origLink>http://lineadecodigo.com/html5/autofoco-a-un-campo-con-html5/</feedburner:origLink></item> <item><title>Controlar volumen de vídeo HTML5 con un Slider</title><link>http://feedproxy.google.com/~r/LineaDeCodigo/~3/Gxp9P-Mh9gg/</link> <comments>http://lineadecodigo.com/linea-de-codigo/controlar-volumen-de-video-html5-con-un-slider/#comments</comments> <pubDate>Fri, 03 Feb 2012 21:00:53 +0000</pubDate> <dc:creator>Víctor Cuervo</dc:creator> <category><![CDATA[Linea de Codigo]]></category> <category><![CDATA[checkbox]]></category> <category><![CDATA[checked]]></category> <category><![CDATA[input]]></category> <category><![CDATA[max]]></category> <category><![CDATA[min]]></category> <category><![CDATA[slider]]></category> <category><![CDATA[step]]></category> <category><![CDATA[value]]></category> <category><![CDATA[video]]></category> <category><![CDATA[volume]]></category> <guid isPermaLink="false">http://lineadecodigo.com/?p=3806</guid> <description><![CDATA[En este ejemplo vamos a combinar varias cosas que hemos aprendido sobre el HTML5. Por un lado el manejo de los sliders para poder establecer un rango de valores mediante una barra de desplazamiento. Por otro el manejo de un vídeo en HTML5. Además aprenderemos una cosa nueva, que será el controlar el volumen del [...]]]></description> <content:encoded><![CDATA[<p>En este ejemplo vamos a combinar varias cosas que hemos aprendido sobre el <a
href="http://www.manualweb.net/tutorial-html5/" title="Manual sobre HTML5">HTML5</a>. Por un lado <a
href="http://lineadecodigo.com/html5/elemento-rango-en-formularios-html5/" title="Manejo de los sliders y el elemento rango en HTML5">el manejo de los sliders para poder establecer un rango de valores mediante una barra de desplazamiento</a>. Por otro <a
href="http://lineadecodigo.com/html5/cargar-un-video-en-html5/" title="Manejo de un video en HTML5">el manejo de un vídeo en HTML5</a>. Además aprenderemos una cosa nueva, que será el controlar el volumen del vídeo con un slider.</p><p>Lo primero que haremos será poner en nuestra página los elementos <a
href="http://www.manualweb.net/tutorial-html5/" title="Manual sobre HTML5">HTML5</a> que necesitemos, ya que el código <a
href="http://www.manualweb.net/tutorial-javascript/" title="Manual de Javascript">Javascript</a> que incorporemos será siempre no intrusivo.</p><p>El vídeo, mediante el elemento <a
href="http://w3api.com/wiki/HTML5:VIDEO" title="Elemento VIDEO de HTML5">VIDEO</a> será el siguiente:</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>Y el slider será mediante un <a
href="http://w3api.com/wiki/HTML5:INPUT" title="Elemento INPUT de HTML5">elemento input</a> y su tipo "range"</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;volumen&quot;</span>&gt;</span>Volumen: <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;range&quot;</span> min<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0&quot;</span> max<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;1&quot;</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;1&quot;</span> step<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0.1&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;volumen&quot;</span>&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;checkbox&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;mute&quot;</span>&gt;&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;mute&quot;</span>&gt;</span>Mute<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></pre><p>Además hemos incorporado un checkbox para simular el mute. Es decir, para quitar el sonido al vídeo.</p><p>Lo primero, las referencias a los elementos:</p><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> mute <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;mute&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<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;volumen&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre><p>Sobre el tema de controlar el volumen del vídeo deberemos de saber que la propiedad que gestiona el volumen de un vídeo en <a
href="http://www.manualweb.net/tutorial-html5/" title="Manual sobre HTML5">HTML5</a> es <a
href="http://w3api.com/wiki/DOM:HTMLMediaElement.volume" title="Atributo volume de HTMLMediaElement">.volume</a> del elemento HTMLMediaElement. Y que los valores que puede tomar dicha propiedad van desde el 0.0 hasta el 1.0 con saltos de 0.1. Algo importante ya que como vemos son los valores que hemos dado a las propiedades <a
href="http://w3api.com/wiki/HTML5:INPUT.min" title="Atributo min del elemento INPUT">min</a>, <a
href="http://w3api.com/wiki/HTML5:INPUT.max" title="Atributo max del elemento INPUT">max</a> y <a
href="http://w3api.com/wiki/HTML5:INPUT.step" title="Atributo step del slider">step</a> del slider.</p><p>Así la codificación ante un cambio del slider, es decir, ante que se produzca un evento change, será el asignar el valor del slider al volumen del vídeo.</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: #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;">volume</span> <span style="color: #339933;">=</span> ev.<span style="color: #660066;">target</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
  mute.<span style="color: #660066;">checked</span><span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">false</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>Vemos en el código que el .value del slider se lo asignamos a la propiedad <a
href="http://w3api.com/wiki/DOM:HTMLMediaElement.volume" title="Atributo volume de HTMLMediaElement">.volume</a> del vídeo.</p><blockquote><p>Utilizamos <a
href="http://w3api.com/wiki/DOM:Element.addEventListener()" title="Méodo addEventListener">.addEventListener</a> para adjuntar la gestión de un evento a un elemento en concreto.</p></blockquote><p>Además hemos añadido el manejo del mute. es decir, si cambiamos el slider (movemos el volumen) se desactivará la casilla del mute.</p><p>Ahora vamos con el mute. Para esto gestionamos el evento change del checkbox. Cada vez que cambie el checkbox veremos que hacer. Pero antes de esto nos vamos a crear una variable que nos permite mantener la información del volumen. Esta nos servirá para que cuando desactivemos el mute, recuperemos la última posición del volumen. A esta variable la hemos llamado oldvolume.</p><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> oldvolume <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span></pre><p>Inicializada a 1, al igual que sucede con el volumen.<br
/> Ahora solo tenemos que jugar con el valor del checkbox. Su atributo .checked nos indicará si este está activo o no.</p><pre class="javascript" style="font-family:monospace;">mute.<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: #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>
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>ev.<span style="color: #660066;">target</span>.<span style="color: #660066;">checked</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		oldvolume <span style="color: #339933;">=</span> v.<span style="color: #660066;">volume</span><span style="color: #339933;">;</span>
		v.<span style="color: #660066;">volume</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
		barra.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
		v.<span style="color: #660066;">volume</span> <span style="color: #339933;">=</span> oldvolume<span style="color: #339933;">;</span>
		barra.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> oldvolume<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</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>La lógica, la siguiente. Si está activado hay que apagar el volumen (atributo volume a 0 y el slider con un valor de 0), pero guardándonos la posición actual del volumen en la variable oldvolume.</p><p>Que el checkbox está desactivado, pues reponemos el valor de la variable oldvolume tanto al slider, como al atributo <a
href="http://w3api.com/wiki/DOM:HTMLMediaElement.volume" title="Atributo volume de HTMLMediaElement">.volume</a> del vídeo.</p><p>Con todo esto ya podemos controlar el volumen de vídeo <a
href="http://www.manualweb.net/tutorial-html5/" title="Manual sobre HTML5">HTML5</a> con un Slider.<strong>Similar Posts:</strong><ul
class="similar-posts"><li><a
href="http://lineadecodigo.com/javascript/contar-checkbox-activos-con-javascript/" rel="bookmark" title="Febrero 8, 2008">Contar checkbox activos con 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/jquery/cambios-en-un-combo-con-jquery/" rel="bookmark" title="Mayo 17, 2011">Cambios en un combo con jQuery</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/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></ul><p></p> 
<p><a href="http://feedads.g.doubleclick.net/~a/19xo4GW237SewhAS6S3-l58YmfE/0/da"><img src="http://feedads.g.doubleclick.net/~a/19xo4GW237SewhAS6S3-l58YmfE/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/19xo4GW237SewhAS6S3-l58YmfE/1/da"><img src="http://feedads.g.doubleclick.net/~a/19xo4GW237SewhAS6S3-l58YmfE/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=Gxp9P-Mh9gg:MX4_dXiZfRA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=Gxp9P-Mh9gg:MX4_dXiZfRA:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?i=Gxp9P-Mh9gg:MX4_dXiZfRA:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=Gxp9P-Mh9gg:MX4_dXiZfRA:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?i=Gxp9P-Mh9gg:MX4_dXiZfRA:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=Gxp9P-Mh9gg:MX4_dXiZfRA:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=Gxp9P-Mh9gg:MX4_dXiZfRA:tKBiNdHYW3c"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?d=tKBiNdHYW3c" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LineaDeCodigo/~4/Gxp9P-Mh9gg" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://lineadecodigo.com/linea-de-codigo/controlar-volumen-de-video-html5-con-un-slider/feed/</wfw:commentRss> <slash:comments>1</slash:comments> <enclosure url="http://easyhtml5video.com/images/happyfit2.ogv" length="10220659" type="video/ogg" /> <feedburner:origLink>http://lineadecodigo.com/linea-de-codigo/controlar-volumen-de-video-html5-con-un-slider/</feedburner:origLink></item> <item><title>Tiempo total de un vídeo HTML5</title><link>http://feedproxy.google.com/~r/LineaDeCodigo/~3/bkT30rww7MI/</link> <comments>http://lineadecodigo.com/html5/tiempo-total-de-un-video-html5/#comments</comments> <pubDate>Thu, 02 Feb 2012 07:00:04 +0000</pubDate> <dc:creator>Víctor Cuervo</dc:creator> <category><![CDATA[HTML5]]></category> <category><![CDATA[addEventListener]]></category> <category><![CDATA[duration]]></category> <category><![CDATA[HTMLMediaElement]]></category> <category><![CDATA[loadeddata]]></category> <category><![CDATA[video]]></category> <guid isPermaLink="false">http://lineadecodigo.com/?p=3798</guid> <description><![CDATA[Cuando cargamos un vídeo en HTML5 puede ser interesante el conocer el tiempo total de la duración del vídeo. El elemento HTMLMediaElement nos permite consultar esta información. Para poder consultar el tiempo total de un vídeo utilizaremos el atributo duration del HTMLMediaElement. var v = document.getElementById&#40;&#34;mivideo&#34;&#41;; document.write&#40;v.duration&#41;; Ahora, que cuando ejecutemos este código nos llevaremos [...]]]></description> <content:encoded><![CDATA[<p>Cuando cargamos un vídeo en <a
href="http://www.manualweb.net/tutorial-html5/" title="Manual de HTML5">HTML5</a> puede ser interesante el conocer el tiempo total de la duración del vídeo. El elemento <a
href="http://www.w3api.com/wiki/DOM:HTMLMediaElement" title="Elemento DOM HTMLMediaElement">HTMLMediaElement</a> nos permite consultar esta información.</p><p>Para poder consultar el tiempo total de un vídeo utilizaremos el <a
href="http://www.w3api.com/wiki/DOM:HTMLMediaElement.duration" title="Atributo duration del HTMLMediaElement">atributo duration</a> del <a
href="http://www.w3api.com/wiki/DOM:HTMLMediaElement" title="Elemento DOM HTMLMediaElement">HTMLMediaElement</a>.</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>
document.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span>v.<span style="color: #660066;">duration</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre><p>Ahora, que cuando ejecutemos este código nos llevaremos una sorpresa y es que, el <a
href="http://www.w3api.com/wiki/DOM:HTMLMediaElement.duration" title="Atributo duration del HTMLMediaElement">atributo duration</a>, no nos devolverá ningún valor. Esto es debido a que la información del tiempo total de un vídeo no es cargada hasta que tenemos la información de los metadatos del vídeo.</p><p>Y, ¿cuándo tenemos los metadatos del vídeo? Para ello tenemos el evento <a
href="http://www.w3api.com/wiki/DOM:HTMLMediaElement.onloadeddata" title="Evento loadeddata">loadeddata</a>. Así que tendremos que poner un listener sobre dicho evento en el elemento video. En este caso utilizaremos el método <a
href="http://www.w3api.com/wiki/DOM:Element.addEventListener()" title="Metodo Javascript addEventListener">.addEventListener()</a> para llevar a cabo dicha tarea.</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;loadeddata&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>Será dentro del listener dónde codifiquemos el acceso al campo duration del <a
href="http://www.w3api.com/wiki/DOM:HTMLMediaElement" title="Elemento DOM HTMLMediaElement">HTMLMediaElement</a> para obtener el tiempo total de un vídeo <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> 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;loadeddata&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;tiempototal&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> v.<span style="color: #660066;">duration</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>Tiempototal es una capa de nuestra página <a
href="http://www.manualweb.net/tutorial-html5/" title="Manual de HTML5">HTML5</a> sobre la que volcaremos el resultado.<strong>Similar Posts:</strong><ul
class="similar-posts"><li><a
href="http://lineadecodigo.com/html5/tiempo-visualizado-del-video-en-html5/" rel="bookmark" title="Febrero 6, 2012">Tiempo visualizado del vídeo en 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/linea-de-codigo/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/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/html5/controlar-un-error-de-carga-de-un-video-en-html5/" rel="bookmark" title="Enero 22, 2012">Controlar un error de carga de un vídeo en HTML5</a></li></ul><p></p> 
<p><a href="http://feedads.g.doubleclick.net/~a/nXx6_fJuiudVGCbJiMmGj5Ejw1g/0/da"><img src="http://feedads.g.doubleclick.net/~a/nXx6_fJuiudVGCbJiMmGj5Ejw1g/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/nXx6_fJuiudVGCbJiMmGj5Ejw1g/1/da"><img src="http://feedads.g.doubleclick.net/~a/nXx6_fJuiudVGCbJiMmGj5Ejw1g/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=bkT30rww7MI:tiP2E7QS8lI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=bkT30rww7MI:tiP2E7QS8lI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?i=bkT30rww7MI:tiP2E7QS8lI:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=bkT30rww7MI:tiP2E7QS8lI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?i=bkT30rww7MI:tiP2E7QS8lI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=bkT30rww7MI:tiP2E7QS8lI:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=bkT30rww7MI:tiP2E7QS8lI:tKBiNdHYW3c"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?d=tKBiNdHYW3c" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LineaDeCodigo/~4/bkT30rww7MI" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://lineadecodigo.com/html5/tiempo-total-de-un-video-html5/feed/</wfw:commentRss> <slash:comments>1</slash:comments> <feedburner:origLink>http://lineadecodigo.com/html5/tiempo-total-de-un-video-html5/</feedburner:origLink></item> <item><title>DataList en HTML5</title><link>http://feedproxy.google.com/~r/LineaDeCodigo/~3/ndGbI4-GA4I/</link> <comments>http://lineadecodigo.com/html5/datalist-en-html5/#comments</comments> <pubDate>Wed, 01 Feb 2012 07:00:53 +0000</pubDate> <dc:creator>Víctor Cuervo</dc:creator> <category><![CDATA[HTML5]]></category> <category><![CDATA[datalist]]></category> <category><![CDATA[id]]></category> <category><![CDATA[input]]></category> <category><![CDATA[label]]></category> <category><![CDATA[List]]></category> <category><![CDATA[OPTION]]></category> <category><![CDATA[range]]></category> <category><![CDATA[URL]]></category> <guid isPermaLink="false">http://lineadecodigo.com/?p=3792</guid> <description><![CDATA[Un DataList en HTML5 es una lista de opciones predefinidas que le podemos pasar al elemento INPUT le podemos aplicar un DataList en HTML5. Pues podemos aplicarlo al tipo text o aun tipo URL o al tipo range. Es decir, de HTML5. Es decir, el agente de usuario o navegador propocionará esa lista como posibles [...]]]></description> <content:encoded><![CDATA[<p>Un <a
href="http://www.w3api.com/wiki/HTML5:DATALIST" title="Elemento DataList de HTML5">DataList</a> en <a
href="http://www.manualweb.net/tutorial-html5/" title="Manual de HTML5">HTML5</a> es una lista de opciones predefinidas que le podemos pasar al elemento <a
href="http://www.w3api.com/wiki/HTML5:INPUT" title="Elemento INPUT en HTML5">INPUT</a> le podemos aplicar un DataList en HTML5. Pues podemos aplicarlo al tipo text o aun tipo URL o al tipo range. Es decir, de <a
href="http://www.manualweb.net/tutorial-html5/" title="Manual de HTML5">HTML5</a>. Es decir, el agente de usuario o navegador propocionará esa lista como posibles opciones.</p><p>Pero, a qué tipos del elemento <a
href="http://www.w3api.com/wiki/HTML5:INPUT" title="Elemento INPUT en HTML5">INPUT</a> le podemos aplicar un <a
href="http://www.w3api.com/wiki/HTML5:DATALIST" title="Elemento DataList de HTML5">DataList</a> en <a
href="http://www.manualweb.net/tutorial-html5/" title="Manual de HTML5">HTML5</a>. Pues podemos aplicarlo al tipo text o aun tipo URL o al tipo range. Es decir, sobre una caja de text o sobre un slider. En el primer caso el <a
href="http://www.w3api.com/wiki/HTML5:DATALIST" title="Elemento DataList de HTML5">DataList</a> serán las opciones propuestas y predefinidas que se le darán al usuario y en el caso del slider serán diferentes puntos dentro del slider.</p><p>Pero lo primero será definir la lista de opciones del <a
href="http://www.w3api.com/wiki/HTML5:DATALIST" title="Elemento DataList de HTML5">DataList</a>. El elemento es <a
href="http://www.w3api.com/wiki/HTML5:DATALIST" title="Elemento DataList de HTML5">datalist</a>.</p><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;datalist <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;lista&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:OPTION"><span style="color: #000000; font-weight: bold;">option</span></a> <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;0&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:OPTION"><span style="color: #000000; font-weight: bold;">option</span></a> <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;2&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:OPTION"><span style="color: #000000; font-weight: bold;">option</span></a> <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;4&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:OPTION"><span style="color: #000000; font-weight: bold;">option</span></a> <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>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:OPTION"><span style="color: #000000; font-weight: bold;">option</span></a> <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;8&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:OPTION"><span style="color: #000000; font-weight: bold;">option</span></a> <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;10&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>datalist&gt;</span></pre><p>Como vemos, la lista tiene un identificador denotado por el <a
href="http://www.w3api.com/wiki/HTML5:Id" title="Atributo id de HTML5">atributo id</a> y una lista de opciones. Cada una de las opciones de la lista la definimos mediante un elemento <a
href="http://www.w3api.com/wiki/HTML5:OPTION" title="Elemento OPTION de Html5">option</a>.</p><p>Si queremos podemos dar a los valores de la lista un texto alternativo. Para ello utilizaremos el <a
href="http://www.w3api.com/wiki/HTML5:OPTION.label" title="Atributo label del elemento OPTION de HTML5">atributo label</a>.</p><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;datalist <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;listaurls&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:OPTION"><span style="color: #000000; font-weight: bold;">option</span></a> <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;http://www.ayudaenlaweb.com&quot;</span> <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;Ayuda en la Web&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:OPTION"><span style="color: #000000; font-weight: bold;">option</span></a> <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;http://lineadecodigo.com&quot;</span> <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;Línea de Código&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:OPTION"><span style="color: #000000; font-weight: bold;">option</span></a> <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;http://www.dudasprogramacion.com&quot;</span> <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;Dudas de Programación&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>datalist&gt;</span></pre><p>Como podemos comprobar la estructura de la lista es realmente sencilla. El siguiente paso será el asociar la lista al elemento <a
href="http://www.w3api.com/wiki/HTML5:INPUT" title="Elemento INPUT en HTML5">INPUT</a>. Para ello utilizamos el <a
href="http://www.w3api.com/wiki/HTML5:INPUT.list" title="Atributo list del INPUT en HTML5">atributo list</a> del <a
href="http://www.w3api.com/wiki/HTML5:INPUT" title="Elemento INPUT en HTML5">INPUT</a>, el cual deberá de hacer referencia al <a
href="http://www.w3api.com/wiki/HTML5:Id" title="Atributo ID de HTML5">id</a> de la lista.</p><p>Así si creamos un input que haga referencia a la primera lista sería:</p><pre class="html4strict" style="font-family:monospace;">&nbsp;
<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;range&quot;</span> min<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0&quot;</span> max<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;10&quot;</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;3&quot;</span> step<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;1&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;mislider&quot;</span> list<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;lista&quot;</span>&gt;</span></pre><p>y si creamos una referencia desde un tipo URL a la segunda lista sería:</p><pre class="html4strict" style="font-family:monospace;">&nbsp;
<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;url&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;misurl&quot;</span> list<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;listaurls&quot;</span> <a href="http://w3api.com/wiki/HTML:size"><span style="color: #000066;">size</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;100&quot;</span>&gt;</span></pre><p>Ya solo nos queda ver el efecto que produce el elemento <a
href="http://www.w3api.com/wiki/HTML5:DATALIST" title="Elemento DataList de HTML5">DataList</a> y su comportamiento de opciones por defecto en nuestro navegador. Eso sí, de momento solo el <a
href="http://www.ayudaenlaweb.com/navegadores/que-es-opera/" title="Navegador web Opera">navegador web Opera</a> da soporte a los <a
href="http://www.w3api.com/wiki/HTML5:DATALIST" title="Elemento DataList de HTML5">DataList</a> de <a
href="http://www.manualweb.net/tutorial-html5/" title="Manual de HTML5">HTML5</a>.<br
/> <strong>Similar Posts:</strong><ul
class="similar-posts"><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/linea-de-codigo/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/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/html5/cargar-un-video-de-diferentes-formatos-con-html5/" rel="bookmark" title="Enero 12, 2012">Cargar un vídeo de diferentes formatos con HTML5</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></p> 
<p><a href="http://feedads.g.doubleclick.net/~a/nrRXUTChPCFizKx_0SgOujzSYWY/0/da"><img src="http://feedads.g.doubleclick.net/~a/nrRXUTChPCFizKx_0SgOujzSYWY/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/nrRXUTChPCFizKx_0SgOujzSYWY/1/da"><img src="http://feedads.g.doubleclick.net/~a/nrRXUTChPCFizKx_0SgOujzSYWY/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=ndGbI4-GA4I:xDmU_RjH_nw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=ndGbI4-GA4I:xDmU_RjH_nw:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?i=ndGbI4-GA4I:xDmU_RjH_nw:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=ndGbI4-GA4I:xDmU_RjH_nw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?i=ndGbI4-GA4I:xDmU_RjH_nw:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=ndGbI4-GA4I:xDmU_RjH_nw:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=ndGbI4-GA4I:xDmU_RjH_nw:tKBiNdHYW3c"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?d=tKBiNdHYW3c" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LineaDeCodigo/~4/ndGbI4-GA4I" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://lineadecodigo.com/html5/datalist-en-html5/feed/</wfw:commentRss> <slash:comments>1</slash:comments> <feedburner:origLink>http://lineadecodigo.com/html5/datalist-en-html5/</feedburner:origLink></item> <item><title>Elemento rango en formularios HTML5</title><link>http://feedproxy.google.com/~r/LineaDeCodigo/~3/Dti4qHi51fc/</link> <comments>http://lineadecodigo.com/html5/elemento-rango-en-formularios-html5/#comments</comments> <pubDate>Tue, 31 Jan 2012 22:59:29 +0000</pubDate> <dc:creator>Víctor Cuervo</dc:creator> <category><![CDATA[HTML5]]></category> <category><![CDATA[addEventListener]]></category> <category><![CDATA[currentTarget]]></category> <category><![CDATA[formulario]]></category> <category><![CDATA[input]]></category> <category><![CDATA[max]]></category> <category><![CDATA[min]]></category> <category><![CDATA[range]]></category> <category><![CDATA[slider]]></category> <category><![CDATA[step]]></category> <category><![CDATA[value]]></category> <guid isPermaLink="false">http://lineadecodigo.com/?p=3782</guid> <description><![CDATA[Una de las novedades que tenemos dentro de los formularios HTML5 son los elementos input de tipo rango. Estos elementos son unos sliders que nos permiten seleccionar un valor desplazando un puntero sobre el slider. Para crear un elemento de tipo rango en formularios HTML5 tenemos que crear un elemento input de tipo range de [...]]]></description> <content:encoded><![CDATA[<p>Una de las novedades que tenemos dentro de los formularios <a
href="http://www.manualweb.net/tutorial-html5/" title="Manual de HTML5">HTML5</a> son los elementos input de tipo rango. Estos elementos son unos sliders que nos permiten seleccionar un valor desplazando un puntero sobre el slider.</p><p>Para crear un elemento de tipo rango en formularios <a
href="http://www.manualweb.net/tutorial-html5/" title="Manual de HTML5">HTML5</a> tenemos que crear un elemento <a
href="http://www.w3api.com/wiki/HTML5:INPUT" title="Elemento INPUT de HTML5">input</a> de tipo range de la siguiente forma:</p><pre class="html4strict" style="font-family:monospace;">&nbsp;
<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;range&quot;</span><span style="color: #66cc66;">/</span>&gt;</span></pre><p>Sobre este elemento podemos definir varios valores. En primer lugar el valor máximo y mínimo del rango. Esto lo haremos mediante los atributos <a
href="http://www.w3api.com/wiki/HTML5:INPUT.min" title="Atributo min del INPUT">min</a> y <a
href="http://www.w3api.com/wiki/HTML5:INPUT.max" title="Atributo max del INPUT">max</a>.</p><pre class="html4strict" style="font-family:monospace;">&nbsp;
<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;range&quot;</span> min<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0&quot;</span> max<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;10&quot;</span><span style="color: #66cc66;">/</span>&gt;</span></pre><p>De igual manera podemos definir los valores del incremento, es decir, cada vez que desplazamos el puntero en cuanto se incrementará o decrementará el valor del elemento. Este atributo es <a
href="http://www.w3api.com/wiki/HTML5:INPUT.step" title="Atributo step del INPUT">step</a>. Así si queremos que se incremente de uno en uno definiremos el elemento rango de la siguiente forma:</p><pre class="html4strict" style="font-family:monospace;">&nbsp;
<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;range&quot;</span> min<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0&quot;</span> max<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;10&quot;</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;3&quot;</span> step<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;1&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;mislider&quot;</span>&gt;</span></pre><p>Los elementos de tipo rango están disponibles vía <a
href="http://www.manualweb.net/tutorial-javascript/" title="Manual de Javascript">Javascript</a>. Es decir, podemos acceder a su modelo DOM y consultar el valor que tiene el rango en cualquier momento. Bastará solo con consultar el valor del atributo value.</p><p>Por ejemplo, si queremos calcular el valor que tiene el rango cada vez que se modifique podemos crear un listener sobre el evento onchange de dicho rango con el método <a
href="http://www.w3api.com/wiki/DOM:Element.addEventListener()" title="Método addEventListener del DOM">addEventListener</a>.</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>
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: #003366; font-weight: bold;">var</span> resultado <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;valor&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  resultado.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> ev.<span style="color: #660066;">currentTarget</span>.<span style="color: #660066;">value</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>Vemos que cuando utilizamos el método <a
href="http://www.w3api.com/wiki/DOM:Element.addEventListener()" title="Método addEventListener del DOM">addEventListener</a> el objeto evento que se le pasa a la función lleva la referencia al elemento que generó el evento en el campo <a
href="http://www.w3api.com/wiki/DOM:Event.currentTarget" title="Campo currentTarget de un Event">currentTarget</a>.</p><p>Solo hay que tener en cuenta una cosa al utilizar el elemento range en formularios <a
href="http://www.manualweb.net/tutorial-html5/" title="Manual de HTML5">HTML5</a> y esto es el soporte de los navegadores, ya que todavía todos no lo dan.<strong>Similar Posts:</strong><ul
class="similar-posts"><li><a
href="http://lineadecodigo.com/linea-de-codigo/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/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/crear-eventos-con-javascript/" rel="bookmark" title="Septiembre 29, 2007">Crear eventos con JavaScript</a></li><li><a
href="http://lineadecodigo.com/html5/controlar-un-error-de-carga-de-un-video-en-html5/" rel="bookmark" title="Enero 22, 2012">Controlar un error de carga de un vídeo en HTML5</a></li><li><a
href="http://lineadecodigo.com/html5/tiempo-visualizado-del-video-en-html5/" rel="bookmark" title="Febrero 6, 2012">Tiempo visualizado del vídeo en HTML5</a></li></ul><p></p> 
<p><a href="http://feedads.g.doubleclick.net/~a/-yRCCkc-L1jG7beaMOPIG09cnYk/0/da"><img src="http://feedads.g.doubleclick.net/~a/-yRCCkc-L1jG7beaMOPIG09cnYk/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/-yRCCkc-L1jG7beaMOPIG09cnYk/1/da"><img src="http://feedads.g.doubleclick.net/~a/-yRCCkc-L1jG7beaMOPIG09cnYk/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=Dti4qHi51fc:BpN6yTgHf18:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=Dti4qHi51fc:BpN6yTgHf18:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?i=Dti4qHi51fc:BpN6yTgHf18:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=Dti4qHi51fc:BpN6yTgHf18:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?i=Dti4qHi51fc:BpN6yTgHf18:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=Dti4qHi51fc:BpN6yTgHf18:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=Dti4qHi51fc:BpN6yTgHf18:tKBiNdHYW3c"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?d=tKBiNdHYW3c" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LineaDeCodigo/~4/Dti4qHi51fc" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://lineadecodigo.com/html5/elemento-rango-en-formularios-html5/feed/</wfw:commentRss> <slash:comments>4</slash:comments> <feedburner:origLink>http://lineadecodigo.com/html5/elemento-rango-en-formularios-html5/</feedburner:origLink></item> <item><title>Comparar con la fecha del sistema en Javascript</title><link>http://feedproxy.google.com/~r/LineaDeCodigo/~3/XwkjpN4RX-4/</link> <comments>http://lineadecodigo.com/javascript/comparar-con-la-fecha-del-sistema-en-javascript/#comments</comments> <pubDate>Mon, 30 Jan 2012 07:00:04 +0000</pubDate> <dc:creator>Víctor Cuervo</dc:creator> <category><![CDATA[JavaScript]]></category> <category><![CDATA[ceil]]></category> <category><![CDATA[Date]]></category> <category><![CDATA[fechas]]></category> <category><![CDATA[getTime]]></category> <category><![CDATA[Math]]></category> <category><![CDATA[resta]]></category> <guid isPermaLink="false">http://lineadecodigo.com/?p=3777</guid> <description><![CDATA[Comparar con la fecha del sistema en Javascript nos sirve para saber la diferencia de fechas entre el día de hoy y otra fecha. Esto nos serviría desde casos en los que queramos saber hace cuanto tiempo publique esta entrada en el blog, o cuánto queda para el día de mi cumpleaños o cuánto queda [...]]]></description> <content:encoded><![CDATA[<p>Comparar con la fecha del sistema en <a
href="http://www.manualweb.net/tutorial-javascript/" title="Tutorial de Javascript">Javascript</a> nos sirve para saber la diferencia de fechas entre el día de hoy y otra fecha. Esto nos serviría desde casos en los que queramos saber hace cuanto tiempo publique esta entrada en el blog, o cuánto queda para el día de mi cumpleaños o cuánto queda hasta año nuevo.</p><p>Realmente lo que estamos haciendo es restar dos fechas en <a
href="http://www.manualweb.net/tutorial-javascript/" title="Tutorial de Javascript">Javascript</a>, la que nos da el usuario contra la fecha del sistema.</p><p>Para obtener la fecha del sistema simplemente instanciaremos un objeto <a
href="http://www.w3api.com/wiki/Javascript:Date" title="Objeto Date de Javascript">Date</a>.</p><pre class="javascript" style="font-family:monospace;">fecha <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre><p>Ahora cogeremos la fecha del usuario. Para ello ya vimos en el ejemplo de <a
href="http://lineadecodigo.com/javascript/convertir-una-cadena-a-fecha-en-javascript/" title="Convertir una cadena de texto en fecha con Javascript">cómo convertir una cadena de texto en una fecha</a> los pasos que teníamos que seguir:</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;calcular&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
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>
&nbsp;
  dia <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;dia&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
  mes <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;mes&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
  annio <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;annio&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
&nbsp;
  fecha_texto <span style="color: #339933;">=</span> annio<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;-&quot;</span><span style="color: #339933;">+</span>mes<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;-&quot;</span><span style="color: #339933;">+</span>dia<span style="color: #339933;">;</span>
&nbsp;
  ms <span style="color: #339933;">=</span> Date.<span style="color: #660066;">parse</span><span style="color: #009900;">&#40;</span>fecha_texto<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  fecha2 <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span>ms<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre><p>Ahora toca la resta, para ejecutar la resta convertimos previamente la dos fechas en milisegundos con el método <a
href="http://www.w3api.com/wiki/Javascript:Date.getTime()" title="Método getTime del objeto Date de Javascript">.getTime()</a>. A este valor lo dividimos por los milisegundos que representan un día (1000 ms * 60 segundos * 60 minutos * 24 horas).</p><p>Por último realizaremos un redondeo apoyándonos en el método <a
href="http://www.w3api.com/wiki/Javascript:Math.ceil()" title="Método ceil del objeto Math de Javascript">.ceil()</a> del objeto <a
href="http://www.w3api.com/wiki/Javascript:Math" title="Objeto Math de Javascript">Math</a> de <a
href="http://www.manualweb.net/tutorial-javascript/" title="Tutorial de Javascript">Javascript</a>.</p><pre class="javascript" style="font-family:monospace;">one_day<span style="color: #339933;">=</span><span style="color: #CC0000;">1000</span><span style="color: #339933;">*</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;">24</span><span style="color: #339933;">;</span>
diferencia <span style="color: #339933;">=</span> Math.<span style="color: #660066;">ceil</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>fecha.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span>fecha2.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span>one_day<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
texto <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>diferencia<span style="color: #339933;">&gt;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span><span style="color: #3366CC;">&quot;Hace &quot;</span> <span style="color: #339933;">+</span> diferencia<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;Dentro de &quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>diferencia<span style="color: #339933;">*-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre><p>Utilizaremos el operador ternario para adecentar nuestra respuesta y diferenciar si la fecha paso (resultado positivo) o todavía no hemos llegado (resultado negativo).<br
/> Ya tenemos nuestra comparación con la fecha del sistema en <a
href="http://www.manualweb.net/tutorial-javascript/" title="Tutorial de Javascript">Javascript</a>.<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/java/obtener-fecha-de-modificacion-de-un-fichero-con-java/" rel="bookmark" title="Enero 19, 2012">Obtener fecha de modificación de un fichero con Java</a></li><li><a
href="http://lineadecodigo.com/java/obtener-la-fecha-en-un-jsp/" rel="bookmark" title="Enero 16, 2008">Obtener la fecha en un JSP</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/java/obtener-fecha-actual-con-java/" rel="bookmark" title="Octubre 16, 2007">Obtener fecha actual con Java</a></li></ul><p></p> 
<p><a href="http://feedads.g.doubleclick.net/~a/RXgo0hroEqAXaO37mp6iM661BCA/0/da"><img src="http://feedads.g.doubleclick.net/~a/RXgo0hroEqAXaO37mp6iM661BCA/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/RXgo0hroEqAXaO37mp6iM661BCA/1/da"><img src="http://feedads.g.doubleclick.net/~a/RXgo0hroEqAXaO37mp6iM661BCA/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=XwkjpN4RX-4:tyNh3vMMZsM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=XwkjpN4RX-4:tyNh3vMMZsM:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?i=XwkjpN4RX-4:tyNh3vMMZsM:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=XwkjpN4RX-4:tyNh3vMMZsM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?i=XwkjpN4RX-4:tyNh3vMMZsM:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=XwkjpN4RX-4:tyNh3vMMZsM:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=XwkjpN4RX-4:tyNh3vMMZsM:tKBiNdHYW3c"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?d=tKBiNdHYW3c" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LineaDeCodigo/~4/XwkjpN4RX-4" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://lineadecodigo.com/javascript/comparar-con-la-fecha-del-sistema-en-javascript/feed/</wfw:commentRss> <slash:comments>4</slash:comments> <feedburner:origLink>http://lineadecodigo.com/javascript/comparar-con-la-fecha-del-sistema-en-javascript/</feedburner:origLink></item> <item><title>Convertir una cadena a fecha en Javascript</title><link>http://feedproxy.google.com/~r/LineaDeCodigo/~3/vL9Fd1ExZkI/</link> <comments>http://lineadecodigo.com/javascript/convertir-una-cadena-a-fecha-en-javascript/#comments</comments> <pubDate>Sun, 29 Jan 2012 22:11:11 +0000</pubDate> <dc:creator>Víctor Cuervo</dc:creator> <category><![CDATA[JavaScript]]></category> <category><![CDATA[addEventListener]]></category> <category><![CDATA[Date]]></category> <category><![CDATA[event]]></category> <category><![CDATA[ISO 8601]]></category> <category><![CDATA[parse]]></category> <category><![CDATA[preventDefault]]></category> <category><![CDATA[RFC822]]></category> <guid isPermaLink="false">http://lineadecodigo.com/?p=3765</guid> <description><![CDATA[En este ejemplo vamos a ver cómo podemos convertir una cadena a una fecha, es decir un elemento Date, en Javascript. A primeras parece que pensar que es algo tan trivial como pasarselo en la inicialización. Pero veremos que tenemos ciertas restricciones. Y es que en el fondo, sí, podemos escribir la siguiente línea de [...]]]></description> <content:encoded><![CDATA[<p>En este ejemplo vamos a ver cómo podemos convertir una cadena a una fecha, es decir un elemento <a
href="http://www.w3api.com/wiki/Javascript:Date" title="Elemento Date de Javascript">Date</a>, en <a
href="http://www.manualweb.net/tutorial-javascript/" title="Tutorial de Javascript">Javascript</a>. A primeras parece que pensar que es algo tan trivial como pasarselo en la inicialización. Pero veremos que tenemos ciertas restricciones.</p><p>Y es que en el fondo, sí, podemos escribir la siguiente línea de código:</p><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> fecha <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Sat, 4 Feb 2012&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre><p>Pero, ¿qué podemos utilizar como cadena de texto? Lo que podemos utilizar es todo aquello que podamos analizar mediante el método <a
href="http://www.w3api.com/wiki/Javascript:Date.parse()" title="Método parse del objeto Date">.parse()</a> del objeto <a
href="http://www.w3api.com/wiki/Javascript:Date" title="Elemento Date de Javascript">Date</a>.</p><pre class="javascript" style="font-family:monospace;">Date.<span style="color: #660066;">parse</span><span style="color: #009900;">&#40;</span>cadena<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre><p>Y si miramos qué soporta el método <a
href="http://www.w3api.com/wiki/Javascript:Date.parse()" title="Método parse del objeto Date">.parse()</a> veremos que el texto que le pasemos tiene que estar en formato <a
href="http://tools.ietf.org/html/rfc822" title="Especificación RFC822">RFC822</a> o <a
href="http://www.w3.org/TR/NOTE-datetime" title="ISO 8601">ISO 8601</a>. Así el método nos devolverá los milisegundos desde el 1 de enero de 1970.</p><p>Si no te apetece leerte que dicen los estándares <a
href="http://tools.ietf.org/html/rfc822" title="Especificación RFC822">RFC822</a> y <a
href="http://www.w3.org/TR/NOTE-datetime" title="ISO 8601">ISO 8601</a> te lo resumiremos en que tienen que ser fechas en formato:</p><pre>dia_semana, dia hora
yyyy-mm-dd</pre><p>Y formatos similares. Así el 4 de febrero del 2012 podría declararse como:</p><pre>Sat 4 Feb 2012 12:20:34
2012-02-04</pre><p>Nosotros, para evitar formateos adicionales vamos a montar la fecha por nuestra cuenta, así que utilizaremos un formulario para pedirle al usuario los datos. El formulario será el siguiente:</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;dia&quot;</span>&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;dia&quot;</span> <a href="http://w3api.com/wiki/HTML:size"><span style="color: #000066;">size</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;2&quot;</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;01&quot;</span>&gt;&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: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;mes&quot;</span>&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;mes&quot;</span> <a href="http://w3api.com/wiki/HTML:size"><span style="color: #000066;">size</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;2&quot;</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;02&quot;</span>&gt;&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: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;annio&quot;</span>&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;annio&quot;</span> <a href="http://w3api.com/wiki/HTML:size"><span style="color: #000066;">size</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;4&quot;</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;2012&quot;</span>&gt;&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;&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: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;calcular&quot;</span>&gt;</span>Calcular Fecha<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;<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>Y ahora, controlando el evento de pulsar sobre el botón, es decir, utilizando un <a
href="http://www.w3api.com/wiki/DOM:Element.addEventListener()" title="Método addEventListener del DOM">addEventListener()</a></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;calcular&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
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>
  ...
<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre><p>Vamos a componer nuestra fecha. Obtenemos los valores del formulario y componemos la fecha en formato yyyy-mm-dd</p><pre class="javascript" style="font-family:monospace;">dia <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;dia&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
mes <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;mes&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
annio <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;annio&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
fecha_texto <span style="color: #339933;">=</span> annio<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;-&quot;</span><span style="color: #339933;">+</span>mes<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;-&quot;</span><span style="color: #339933;">+</span>dia<span style="color: #339933;">;</span></pre><p>Lo siguiente será parsearla y crear una fecha (aunque podríamos haber hecho solo lo segundo)</p><pre class="javascript" style="font-family:monospace;">ms <span style="color: #339933;">=</span> Date.<span style="color: #660066;">parse</span><span style="color: #009900;">&#40;</span>fecha_texto<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
fecha <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span>ms<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre><p>Por último volcamos el contenido del Date a un campo y bloqueamos que se lance el evento del botón con <a
href="http://www.w3api.com/wiki/DOM:Event.preventDefault()" title="Método preventDefault sobre un Evento">.preventDefault()</a> para poder ver el resultado y no enviar el formulario.</p><pre class="javascript" style="font-family:monospace;">document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;fecha&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> fecha<span style="color: #339933;">;</span>
ev.<span style="color: #660066;">preventDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre><p>El código entero del manejador quedaría de la siguiente forma:</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;calcular&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
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>
&nbsp;
	dia <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;dia&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
	mes <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;mes&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
	annio <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;annio&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
&nbsp;
	fecha_texto <span style="color: #339933;">=</span> annio<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;-&quot;</span><span style="color: #339933;">+</span>mes<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;-&quot;</span><span style="color: #339933;">+</span>dia<span style="color: #339933;">;</span>
&nbsp;
	ms <span style="color: #339933;">=</span> Date.<span style="color: #660066;">parse</span><span style="color: #009900;">&#40;</span>fecha_texto<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	fecha <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span>ms<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;fecha&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> fecha<span style="color: #339933;">;</span>
	ev.<span style="color: #660066;">preventDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">false</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/comparar-con-la-fecha-del-sistema-en-javascript/" rel="bookmark" title="Enero 30, 2012">Comparar con la fecha del sistema en Javascript</a></li><li><a
href="http://lineadecodigo.com/vbscript/fecha-en-castellano-con-vbscript/" rel="bookmark" title="Enero 18, 2007">Fecha en castellano con VBScript</a></li><li><a
href="http://lineadecodigo.com/html5/tiempo-visualizado-del-video-en-html5/" rel="bookmark" title="Febrero 6, 2012">Tiempo visualizado del vídeo en HTML5</a></li><li><a
href="http://lineadecodigo.com/java/obtener-fecha-de-modificacion-de-un-fichero-con-java/" rel="bookmark" title="Enero 19, 2012">Obtener fecha de modificación de un fichero con Java</a></li><li><a
href="http://lineadecodigo.com/jquery/evitar-que-se-ejecute-un-evento-con-jquery/" rel="bookmark" title="Junio 11, 2010">Evitar que se ejecute un evento con jQuery</a></li></ul><p></p> 
<p><a href="http://feedads.g.doubleclick.net/~a/J8Ls_uRnKsBpnra9hTAW6LAU5SA/0/da"><img src="http://feedads.g.doubleclick.net/~a/J8Ls_uRnKsBpnra9hTAW6LAU5SA/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/J8Ls_uRnKsBpnra9hTAW6LAU5SA/1/da"><img src="http://feedads.g.doubleclick.net/~a/J8Ls_uRnKsBpnra9hTAW6LAU5SA/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=vL9Fd1ExZkI:cz3ftbVLgus:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=vL9Fd1ExZkI:cz3ftbVLgus:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?i=vL9Fd1ExZkI:cz3ftbVLgus:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=vL9Fd1ExZkI:cz3ftbVLgus:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?i=vL9Fd1ExZkI:cz3ftbVLgus:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=vL9Fd1ExZkI:cz3ftbVLgus:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=vL9Fd1ExZkI:cz3ftbVLgus:tKBiNdHYW3c"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?d=tKBiNdHYW3c" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LineaDeCodigo/~4/vL9Fd1ExZkI" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://lineadecodigo.com/javascript/convertir-una-cadena-a-fecha-en-javascript/feed/</wfw:commentRss> <slash:comments>3</slash:comments> <feedburner:origLink>http://lineadecodigo.com/javascript/convertir-una-cadena-a-fecha-en-javascript/</feedburner:origLink></item> <item><title>Convertir segundos en formato hora con Javascript</title><link>http://feedproxy.google.com/~r/LineaDeCodigo/~3/U3udejsEjnc/</link> <comments>http://lineadecodigo.com/javascript/convertir-segundos-en-formato-hora-con-javascript/#comments</comments> <pubDate>Mon, 23 Jan 2012 07:00:37 +0000</pubDate> <dc:creator>Víctor Cuervo</dc:creator> <category><![CDATA[JavaScript]]></category> <category><![CDATA[?:]]></category> <category><![CDATA[Date]]></category> <category><![CDATA[getHours()]]></category> <category><![CDATA[getMinutes()]]></category> <category><![CDATA[getSeconds()]]></category> <category><![CDATA[horas]]></category> <category><![CDATA[segundos]]></category> <guid isPermaLink="false">http://lineadecodigo.com/?p=3760</guid> <description><![CDATA[Ciertos sistemas o propiedades nos pueden dar datos en formato de segundos. Si estamos en ese caso y queramos convertir segundos en formato hora con Javascript deberemos de seguir los siguientes pasos. Lo primero será guardar en una variable los segundos: segundos = 1341; Ahora instanciaremos un objeto de Tipo Date. La inicialización del objeto [...]]]></description> <content:encoded><![CDATA[<p>Ciertos sistemas o propiedades nos pueden dar datos en formato de segundos. Si estamos en ese caso y queramos convertir segundos en formato hora con <a
href="http://www.manualweb.net/tutorial-javascript/" title="Tutorial de Javascript">Javascript</a> deberemos de seguir los siguientes pasos.</p><p>Lo primero será guardar en una variable los segundos:</p><pre class="javascript" style="font-family:monospace;">segundos <span style="color: #339933;">=</span> <span style="color: #CC0000;">1341</span><span style="color: #339933;">;</span></pre><p>Ahora instanciaremos un objeto de Tipo Date. La inicialización del objeto <a
href="http://www.w3api.com/wiki/Javascript:Date" title="Objeto Date en Javascript">Date</a> es mediante milisegundos, por lo que necesitaremos multiplicar por 1000 nuestro valor en segundos.</p><pre class="javascript" style="font-family:monospace;"><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></pre><p>Ahora solo tenemos que acceder a los métodos del objeto <a
href="http://www.w3api.com/wiki/Javascript:Date" title="Objeto Date en Javascript">Date</a>. Al <a
href="http://www.w3api.com/wiki/Javascript:Date.getHours()" title="Método getHours del objeto Date Javascript">.getHours()</a>, <a
href="http://www.w3api.com/wiki/Javascript:Date.getMinutes()" title="Metodo getMinutes del objeto Date de Javascript">getMinutes()</a> y <a
href="http://www.w3api.com/wiki/Javascript:Date.getSeconds()" title="Método getSeconds del objeto Date de Javascript">getSeconds()</a>. Estos nos dará los valores en formato hora.</p><pre class="javascript" style="font-family:monospace;"><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></pre><p>De este código hay que fijarse en dos cosas. La primera es que el valor de la hora retornará una hora más de la que realmente es. Es por ello que hacemos la corrección.</p><pre class="javascript" style="font-family:monospace;"><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></pre><p>Y lo segundo en lo que debemos de fijarnos es en el uso del operador ternario para poner los minutos, segundos y horas en un formato de dos dígitos. Y es que los valores inferiores al 10 siempre vendrán solos. Es decir, 1, 2, 3, 4,... cuando nosotros queremos poner 01, 02, 03, 04,...</p><p>Solo quedará volcar el contenido y añadir los dos puntos:</p><pre class="javascript" style="font-family:monospace;">document.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</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: #009900;">&#41;</span><span style="color: #339933;">;</span></pre><p>Ya hemos visto que con el uso del objeto <a
href="http://www.w3api.com/wiki/Javascript:Date" title="Objeto Date en Javascript">Date</a> hemos conseguido convertir segundos en formato hora con <a
href="http://www.manualweb.net/tutorial-javascript/" title="Tutorial de Javascript">Javascript</a>.<strong>Similar Posts:</strong><ul
class="similar-posts"><li><a
href="http://lineadecodigo.com/javascript/reloj-en-javascript/" rel="bookmark" title="Septiembre 6, 2009">Reloj en JavaScript</a></li><li><a
href="http://lineadecodigo.com/javascript/reloj-javascript-en-una-capa/" rel="bookmark" title="Marzo 9, 2010">Reloj Javascript en una capa</a></li><li><a
href="http://lineadecodigo.com/asp/reloj-con-la-hora-del-servidor/" rel="bookmark" title="Septiembre 7, 2009">Reloj con la hora del servidor</a></li><li><a
href="http://lineadecodigo.com/html5/tiempo-visualizado-del-video-en-html5/" rel="bookmark" title="Febrero 6, 2012">Tiempo visualizado del vídeo en HTML5</a></li><li><a
href="http://lineadecodigo.com/java/obtener-fecha-de-modificacion-de-un-fichero-con-java/" rel="bookmark" title="Enero 19, 2012">Obtener fecha de modificación de un fichero con Java</a></li></ul><p></p> 
<p><a href="http://feedads.g.doubleclick.net/~a/zdj74YcMS6LqyjEpJnuAxo3upb0/0/da"><img src="http://feedads.g.doubleclick.net/~a/zdj74YcMS6LqyjEpJnuAxo3upb0/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/zdj74YcMS6LqyjEpJnuAxo3upb0/1/da"><img src="http://feedads.g.doubleclick.net/~a/zdj74YcMS6LqyjEpJnuAxo3upb0/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=U3udejsEjnc:tptE546BMKE:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=U3udejsEjnc:tptE546BMKE:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?i=U3udejsEjnc:tptE546BMKE:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=U3udejsEjnc:tptE546BMKE:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?i=U3udejsEjnc:tptE546BMKE:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=U3udejsEjnc:tptE546BMKE:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LineaDeCodigo?a=U3udejsEjnc:tptE546BMKE:tKBiNdHYW3c"><img src="http://feeds.feedburner.com/~ff/LineaDeCodigo?d=tKBiNdHYW3c" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LineaDeCodigo/~4/U3udejsEjnc" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://lineadecodigo.com/javascript/convertir-segundos-en-formato-hora-con-javascript/feed/</wfw:commentRss> <slash:comments>3</slash:comments> <feedburner:origLink>http://lineadecodigo.com/javascript/convertir-segundos-en-formato-hora-con-javascript/</feedburner:origLink></item> </channel> </rss><!-- Dynamic page generated in 1.271 seconds. --><!-- Cached page generated by WP-Super-Cache on 2012-02-07 12:48:38 --><!-- Compression = gzip -->

