<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>innerhtml &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/innerhtml/</link>
	<description>Feed of posts on WordPress.com tagged "innerhtml"</description>
	<pubDate>Sat, 05 Dec 2009 20:37:47 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[Cflayout]]></title>
<link>http://ppshein.wordpress.com/2009/11/13/cflayout/</link>
<pubDate>Fri, 13 Nov 2009 02:46:28 +0000</pubDate>
<dc:creator>ppshein</dc:creator>
<guid>http://ppshein.wordpress.com/2009/11/13/cflayout/</guid>
<description><![CDATA[I didn&#8217;t notice cflayout tag is just like DIV before. It&#8217;s not much different between cf]]></description>
<content:encoded><![CDATA[I didn&#8217;t notice cflayout tag is just like DIV before. It&#8217;s not much different between cf]]></content:encoded>
</item>
<item>
<title><![CDATA[Usando JavaScript para mostrar contenido]]></title>
<link>http://luistorres.wordpress.com/2009/10/20/usando-javascript-para-mostrar-contenido/</link>
<pubDate>Tue, 20 Oct 2009 00:24:53 +0000</pubDate>
<dc:creator>Luis</dc:creator>
<guid>http://luistorres.wordpress.com/2009/10/20/usando-javascript-para-mostrar-contenido/</guid>
<description><![CDATA[Para mostrar contenido utilizando JavaScript, podemos utilizar varias alternativas, pero en este pos]]></description>
<content:encoded><![CDATA[Para mostrar contenido utilizando JavaScript, podemos utilizar varias alternativas, pero en este pos]]></content:encoded>
</item>
<item>
<title><![CDATA[Check Page Change By User Or Not(JavaScript)]]></title>
<link>http://kuanglian2000.wordpress.com/2009/09/08/check-page-change-by-user-or-notjavascript/</link>
<pubDate>Tue, 08 Sep 2009 02:49:46 +0000</pubDate>
<dc:creator>kuanglian2000</dc:creator>
<guid>http://kuanglian2000.wordpress.com/2009/09/08/check-page-change-by-user-or-notjavascript/</guid>
<description><![CDATA[var originalHeader; var originalDetail; function checkChange() { var currentHeader = getInnerHTML(]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>var originalHeader;<br />
var originalDetail;<br />
function checkChange()<br />
{<br />
var currentHeader = getInnerHTML(&#8216;header&#8217;);<br />
var currentDetail = getInnerHTML(&#8216;detail&#8217;);<br />
if (currentHeader != originalHeader) alert(&#8216;headerChange&#8217;);<br />
if (currentDetail != originalDetail) alert(&#8216;detailChange&#8217;);<br />
}</p>
<p>function BodyLoad()<br />
{<br />
originalHeader = getInnerHTML(&#8216;header&#8217;);<br />
originalDetail = getInnerHTML(&#8216;detail&#8217;);<br />
}</p>
<p>function getInnerHTML(id)<br />
{<br />
var obj=document.getElementById(id);<br />
if(obj!=null)<br />
return obj.innerHTML;<br />
else<br />
return &#8220;&#8221;;<br />
}</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[IE Whitespace madness]]></title>
<link>http://brooknovak.wordpress.com/2009/08/23/ie-whitespace-madness/</link>
<pubDate>Sun, 23 Aug 2009 05:07:59 +0000</pubDate>
<dc:creator>brooknovak</dc:creator>
<guid>http://brooknovak.wordpress.com/2009/08/23/ie-whitespace-madness/</guid>
<description><![CDATA[Internet Explorer&#8217;s DOM has a few issues regarding whitespace. Whitespace symbols in HTML 4.01]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Internet Explorer&#8217;s DOM has a few issues regarding whitespace. Whitespace symbols in HTML 4.01 are any of the following symbols:</p>
<p><!--more--></p>
<ul>
<li>ASCII space (&#38;#x20;)</li>
<li>ASCII tab (&#38;#x09;)</li>
<li>ASCII form feed (&#38;#x0C;)</li>
<li>Zero-width space (&#38;#x200B;)</li>
</ul>
<p>Refer to <a href="http://www.w3.org/TR/html401/struct/text.html#h-9.1">w3&#8217;s specifications here</a>.</p>
<h2>Querying InnerHTML and outerHTML</h2>
<p>Now IE&#8217;s <code>innerHTML</code> and <code>outerHTML</code> adds all sorts of whitespaces when querying these properties. For example:</p>
<pre class="brush: jscript;">
    var container = document.createElement(&quot;div&quot;);
    container.innerHTML = &quot;&lt;div&gt;&lt;ul&gt;&lt;li&gt;I &lt;em&gt;like&lt;/em&gt; sushi!&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&quot;
    alert(container.innerHTML);
</pre>
<p>Prints:</p>
<pre class="brush: xml;">
&lt;DIV&gt;[][]&lt;UL&gt;[][]&lt;LI&gt;I &lt;EM&gt;like&lt;/EM&gt; sushi!&lt;/LI&gt;&lt;/UL&gt;&lt;/DIV&gt;
</pre>
<p>Where the &#8220;[]&#8221; symbols denote whitespace symbols. In this example the added whitespaces causes the alert to break them (probably a newline and carriage return) thus physically displaying:</p>
<pre class="brush: xml;">
&lt;DIV&gt;
&lt;UL&gt;
&lt;LI&gt;I &lt;EM&gt;like&lt;/EM&gt; sushi!&lt;/LI&gt;&lt;/UL&gt;&lt;/DIV&gt;
</pre>
<p>Maybe the implementor was trying to be helpful by adding these mysterious newline symbols before every block-level element for automatic readability. What a damn fool.</p>
<p>Is there a fix? Well, if you really need <code>innerHTML</code> to be precise you could walk the DOM tree yourself and spit out the markup as you traverse. You could bite the bullet can parse the string using regular expressions &#8211; and for every opening block-level element tag check for preceding whitespace symbols and eat them.</p>
<h2>Creating DOM trees via innerHTML</h2>
<p>When creating DOM trees via <code>innerHTML</code>, IE does not always create a DOM tree to reflect the exact HTML contents you pass it. This is because IE automatically collapses whitespace (normalization on the fly). For example:</p>
<pre class="brush: jscript;">
    var container = document.createElement(&quot;div&quot;);
    container.innerHTML = &quot;\n Apples \n&quot;
    alert(container.firstChild.nodeValue.length);
</pre>
<p>All browsers except for IE print &#8220;10&#8243;, IE collapses the surrounding whitespace and prints &#8220;7&#8243;.</p>
<p>To over come this: don&#8217;t use <code>innerHTML</code> &#8211; if you need the DOM tree to be precise, manually create the DOM structures yourself. I tried using &#8220;pre&#8221; white-space styles but it still normalized. You could use a pre element but if you HTML contains block-level elements the markup will be invalid (pre only allows a select few of inline-level elements).</p>
<p><em>Note:</em> you may find this useful: <a href="http://brooknovak.wordpress.com/software-projects/html2js">JS2HTML</a></p>
<p>See <a href="http://www.quirksmode.org/bugreports/archives/2004/11/innerhtml_and_t.html">this bug report at quirksmode</a> for more details.</p>
<p>Hope this article relieves some of your IE headaches&#8230; it probably just aggravated you.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[ JavaScript innerHTML]]></title>
<link>http://mywebdunia.wordpress.com/2009/08/06/javascript-innerhtml/</link>
<pubDate>Thu, 06 Aug 2009 06:15:53 +0000</pubDate>
<dc:creator>Amit Nazare</dc:creator>
<guid>http://mywebdunia.wordpress.com/2009/08/06/javascript-innerhtml/</guid>
<description><![CDATA[You people might be wondering how you could change the contents of an HTML element? like to replace ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>You people might be wondering how you could change the contents of an HTML element? like to replace the innerhtml with the one selected from the select box. Its very easy, you&#8217;ll be able to change your text and HTML as much as you like with the help of JavaScript innerHTML.</p>
<p>Many HTML elements rather you can say each HTML element  have an innerHTML property, and this property allows you to access the text related to an element and modify it. </p>
<p>However, using innerHTML requires some preparation if you want to be able to use it easily and reliably. First, you must give the element you wish to change an <strong>id</strong> thats very important. With that <strong>id</strong> in place you will be able to use the <strong>getElementById </strong>function, which works on all browsers.</p>
<p>For Eample:<br />
here is the JavaScript Code:</p>
<p>&#60;script type=&#8221;text/javascript&#8221;&#62;<br />
function changeText(){<br />
	document.getElementById(&#8216;chngTxt&#8217;).innerHTML = &#8216;the world of Mywebdunia&#8217;;<br />
}<br />
&#60;/script&#62;<br />
&#60;p&#62;Welcome to &#60;b id=&#8217;chngTxt&#8217;&#62;mysite&#60;/b&#62; &#60;/p&#62;<br />
&#60;input type=&#8217;button&#8217; onclick=&#8217;changeText()&#8217; value=&#8217;Change Text&#8217;/&#62;</p>
<p>thats it very simple, try it out yourself.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Character substitution on Jquery]]></title>
<link>http://chirale.wordpress.com/2009/07/04/character-substitution-on-jquery/</link>
<pubDate>Sat, 04 Jul 2009 10:08:26 +0000</pubDate>
<dc:creator>chirale</dc:creator>
<guid>http://chirale.wordpress.com/2009/07/04/character-substitution-on-jquery/</guid>
<description><![CDATA[Here an easy way to search and replace each occurrence a group of characters (in this case underscor]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Here an easy way to <strong>search and replace each occurrence a group of characters</strong> (in this case underscore and minus) with another (in this case a space) on a specified element (in this case each A), using Jquery javascript library.</p>
<pre>
$("a").each(function() {
   $(this).html($(this).html().replace(/[_-]/g," "));
});
</pre>
<p>The first argument passed on <em>replace</em> is a <a href="http://en.wikipedia.org/wiki/Regex" target="_blank">regex</a>, if you just pass a single character (like &#8220;_&#8221; or &#8220;-&#8221;) only first occurrence for each element.</p>
<p><em>Real world usage: I use this onto a long page, where a table has long filenames with underscore and minus in place of spaces. This trick allows in my case to show tables nicely, without caring on a mass substitution via server side scripting.</em></p>
<p><strong>See also:</strong></p>
<ul>
<li><a href="http://evolt.org/regexp_in_javascript">Regex in Javascript</a> &#8211; an useful guide</li>
<li><a href="http://docs.jquery.com/Utilities/jQuery.each">Jquery each</a> &#8211; to match all specified elements</li>
<li><a href="http://docs.jquery.com/Attributes/html">Jquery html()</a> &#8211; read and write html content (innerHTML) of an element</li>
</ul>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[innerHTML n&atilde;o funciona no IE?]]></title>
<link>http://iuribarrablog.wordpress.com/2009/05/28/innerhtml-no-funciona-no-ie-2/</link>
<pubDate>Thu, 28 May 2009 20:28:47 +0000</pubDate>
<dc:creator>Iuri</dc:creator>
<guid>http://iuribarrablog.wordpress.com/2009/05/28/innerhtml-no-funciona-no-ie-2/</guid>
<description><![CDATA[Outro dia eu estava tentando criar um elemento numa página que com um click ele disponibilizasse num]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p align="justify">Outro dia eu estava tentando criar um elemento numa página que com um click ele disponibilizasse num elemento html logo abaixo os dados coletados de uma consulta SQL. Só que mais uma vez lá vem o <strong>IE</strong> estragar tudo com o padrão deles que eu não sei porquê eles acham que é o correto e o resto do mundo é errado.</p>
<p align="justify">O <strong>IE</strong> não deixa você disponibilizar um innerHTML em um elemento já criado dentro da HTML, por alguma razão eu não estava conseguindo. Até que pesquisando através do nosso amigo google eu encontrei uma solução em um blog que infelizmente não to lembrando aqui pra referênciar mas o importante é dizer que a idéia é boa e não é minha. Eis o código:</p>
<div class="csharpcode">
<pre><span class="lnum">   1:  </span>function updatePage(){</pre>
<pre><span class="lnum">   2:  </span>   ...</pre>
<pre><span class="lnum">   3:  </span>    <span class="kwrd">if</span>(request.readyState == 4){</pre>
<pre><span class="lnum">   4:  </span>        clearText(resultEl);</pre>
<pre><span class="lnum">   5:  </span>        <span class="kwrd">if</span>(request.status == 200){</pre>
<pre><span class="lnum">   6:  </span>            <span class="rem">//var txtEl = request.responseText;</span></pre>
<pre><span class="lnum">   7:  </span>            var auxdiv = document.createElement(<span class="str">"div"</span>);</pre>
<pre><span class="lnum">   8:  </span>            auxdiv.innerHTML = request.responseText;</pre>
<pre><span class="lnum">   9:  </span>            resultEl.appendChild(auxdiv);</pre>
<pre><span class="lnum">  10:  </span>        }</pre>
<pre><span class="lnum">  11:  </span>    }</pre>
<pre><span class="lnum">  12:  </span>}</pre>
</div>
<p align="justify">Ou seja, para resolver o problema no <strong>IE</strong> e fazer com que o código funcione nos outros browsers (Firefox e Chrome testados). A solução simples foi criar um elemeno div auxiliar e colocar o innerHTM contendo a resposta do servidor dentro dele. O resultado para o meu código pode ser visto nesse <a href="http://www.ourobranco.rn.gov.br/" target="_blank">link</a> na parte <strong>Atos e Decretos</strong>. Qualquer sugestão ou crítica ou pergunta, comentários abertos! Abraços.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Ajax – Enviar Conteúdo de Formulário via POST com DOJO]]></title>
<link>http://ahaprogramando.wordpress.com/2009/04/27/ajax-enviar-conteudo-de-formulario-via-post-com-dojo/</link>
<pubDate>Mon, 27 Apr 2009 15:30:57 +0000</pubDate>
<dc:creator>Leonir Zimmermann</dc:creator>
<guid>http://ahaprogramando.wordpress.com/2009/04/27/ajax-enviar-conteudo-de-formulario-via-post-com-dojo/</guid>
<description><![CDATA[Ajax (aquela maneira genial de atualizar conteúdo em uma página) tem sido a sensação nos últimos ano]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p class="western" style="margin-bottom:0;" align="center">
<p class="western" style="margin-bottom:0;" align="center">
<p class="western" style="margin-bottom:0;" align="justify">Ajax (aquela maneira genial de atualizar conteúdo em uma página) tem sido a sensação nos últimos anos de desenvolvimento WEB. Lembro das minhas primeiras investidas na área em 2005, naquela época ainda um terreno desconhecido (pra mim) e bastante pedregoso. Anos mais tarde temos diversas ferramentas prontas e gratuitas para desenvolver tarefas em Ajax.<br />
Mas nem só para atualizar conteúdo na página serve o famigerado recurso, pois Ajax é como um portal na quarta dimensão que pode ser aberto no browser e que permite tráfego de dados nas duas direções [servidor &#62; cliente] e [cliente &#62; servidor]. No presente artigo vamos tratar do último caso: “como enviar dados de um formulário para o servidor sem recarregar a página toda após o envio?”</p>
<p class="western" style="margin-bottom:0;" align="justify">Nas minhas primeiras empreitadas nesta área vi que o terreno era árduo e acabei desistindo, mas a biblioteca dojo oferece uma solução com estilo.</p>
<p class="western" style="margin-bottom:0;" align="justify">Se vc ainda não conhece a biblioteca Javascript Dojo, recomendo uma olhada no artigo “Como funciona a biblioteca Javascript Dojo”, será de grande valia <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p class="western" style="margin-bottom:0;" align="justify">
<h2 class="western" style="margin-bottom:0;"><strong>Um pouco de Teoria</strong></h2>
<p class="western" style="margin-bottom:0;font-weight:normal;" align="justify">Vejamos o que ocorre em uma situação de envio tradicional. Na figura 1, podemos identificar 2 arquivos principais, o da página index, ao qual foi incluso um formulário, e o arquivo que recebe os dados. Nestas circunstâncias o envio dos dados é definido simplesmente pelo atributo “action” da tag &#60;form&#62; e o método de envio (geralmente ”post”) é definido no atributo “method” da mesma tag. A tarefa é acionada quando o usuário clicar no botão definido pela tag &#60;submit&#62;.</p>
<p class="western" style="margin-bottom:0;font-weight:normal;" align="justify"><span style="color:#0000ff;">No protocolo HTTP, o browser envia alguma informação ao servidor, e este precisa retornar uma resposta ao browser.</span></p>
<p class="western" style="margin-bottom:0;font-weight:normal;" align="justify">
<p class="western" style="margin-bottom:0;font-weight:normal;" align="justify">No momento do envio, a página toda sai de cena, e o browser envia uma requisição via HTTP ao servidor, para que o arquivo recebe_dados.php entre em ação.</p>
<p class="western" style="margin-bottom:0;" align="justify">
<div id="attachment_77" class="wp-caption alignnone" style="width: 409px"><img class="size-full wp-image-77" title="Envio de dados via post pelo método tradicional." src="http://ahaprogramando.wordpress.com/files/2009/04/metodo_com_post_http2.png" alt="Figura 1 - Envio de dados via post pelo método tradicional" width="399" height="205" /><p class="wp-caption-text">Figura 1 - Envio de dados via post pelo método tradicional</p></div>
<p class="western" style="margin-bottom:0;" align="justify">Este arquivo efetua as tarefas subseqüentes como gravar as informações no Banco de Dados, e após envia um cabeçalho (header) ao browser, com uma diretiva para que o browser peça ao servidor novamente o carregamento de index.php. A URL desta diretiva pode conter uma variável com a resposta dizendo “Ok tudo ocorreu bem!”, ou “Heitaaa, deu problema!”.</p>
<p class="western" style="margin-bottom:0;" align="justify">
<p class="western" style="margin-bottom:0;" align="justify">Ex do código:</p>
<p class="western" style="margin-bottom:0;" align="justify"><span style="color:#000000;"><span style="font-family:Verdana,sans-serif;"><span style="font-size:x-small;">&#60;?<br />
//tarefas</span></span></span><span style="color:#000000;"><br />
…<span style="font-family:Verdana,sans-serif;"><span style="font-size:x-small;"><br />
//retorno<br />
header(“<span style="color:#c5000b;">location:index.php?resposta=</span>”.<span style="color:#008000;">$resposta</span>);<br />
?&#62;</span></span></span></p>
<p class="western" style="margin-bottom:0;" align="justify">Bom, este é o cenário tradicional que todo WEB designer com experiência de formulários conhece.</p>
<p class="western" style="margin-bottom:0;" align="justify">A proposta deste post (aqui post significa artigo do blog hahaha), como dito anteriormente, é utilizar Ajax para que a página não saia de cena enquanto os dados são enviados para recebe_dados.php.</p>
<p class="western" style="margin-bottom:0;" align="justify"><span style="color:#0000ff;">Tenha em mente que Ajax é um método de transferência de dados todo manipulado via Javascript. </span></p>
<p class="western" style="margin-bottom:0;" align="justify">A <strong>figura 2</strong> ilustra o esquema que vamos utilizar com a API do Dojo, o xhrPost.</p>
<p class="western" style="margin-bottom:0;" align="justify">
<p class="western" style="margin-bottom:0;" align="justify">
<p class="western" style="margin-bottom:0;" align="justify">
<div id="attachment_78" class="wp-caption alignnone" style="width: 410px"><img class="size-full wp-image-78" title="Envio de dados com com dojo xhrPost, uma prática maneira de efetuar o envio via Ajax." src="http://ahaprogramando.wordpress.com/files/2009/04/metodo_com_xhrpost1.png" alt="Figura 2 - Envio de dados com dojo xhrPost" width="400" height="472" /><p class="wp-caption-text">Figura 2 - Envio de dados com dojo xhrPost</p></div>
<p class="western" style="margin-bottom:0;" align="justify">Nesta figura procurei deixar claro que os dados contidos no Formulário agora pegam outro trajeto. Veja que agora, o xhrPost, dentro da própria página index.php é quem captura os dados contidos no formulário, e os envia para recebe_dados.php. Ele é uma espécie de agente atravessador que negocia a transferência dos dados, digamos&#8230; por debaixo dos panos, e ninguém vê que algo está indo para o servidor, pois index.php não sai de cena.</p>
<p class="western" style="margin-bottom:0;" align="justify">Assim, se faz necessário também uma modificação na forma do envio da resposta que recebe_dados.php deseja devolver a index.php. Veja que quem está em contado com o servidor neste momento não é o browser todo, mas apenas o objeto xhrPost, ele mesmo fica aguardando a resposta, a qual pode ser um outro HTML, ou um TEXTO qualquer. Mas não desejamos um simples texto, porém uma variável contendo um texto de resposta. Quando vc quer codificar variáveis com valores em um meio textual, geralmente se utiliza XML, JSON, CSV ou coisa parecida. Neste caso, o dojo oferece uma ferramenta simples para codificar as variáveis em JSON.</p>
<p class="western" style="margin-bottom:0;" align="justify">Quando o xhrPost recebe a resposta, ele a pode entregar para funções Javascript específicas que vão decodificar o resultado em JSON e por fim apresentar a mensagem na tela do usuário.</p>
<p class="western" style="margin-bottom:0;" align="justify">Enfim este é o efeito que desejamos. Vamos ás instruções?</p>
<p class="western" style="margin-bottom:0;" align="justify">
<h2 class="western" style="margin-bottom:0;font-weight:normal;">Material necessário:</h2>
<p class="western" style="margin-bottom:0;font-weight:normal;" align="justify"><strong>Básico:</strong></p>
<ol>
<li>Arquivo 			HTML  com formulário básico ( index.php )</li>
<li>Arquivo 			para receber os dados e devolver uma resposta (recebe_dados.php)</li>
<li>Biblioteca 			Javascript Dojo (veja como instalar aqui mesmo no Ahã&#8230; Programando&#8230;:  <a title="Instalação da Biblioteca Dojo" href="http://ahaprogramando.wordpress.com/2009/04/26/instalacao-da-biblioteca-dojo/" target="_blank">instalacao-da-biblioteca-dojo</a>)</li>
</ol>
<p class="western" style="margin-bottom:0;font-weight:normal;" align="justify"><span style="color:#000000;"><span style="font-family:Verdana,sans-serif;"><span style="font-size:x-small;"> </span></span></span></p>
<p class="western" style="margin-bottom:0;" align="justify"><strong>Ferramentas pertencentes ao dojo:</strong></p>
<ol>
<li>
<p class="western" style="margin-bottom:0;" align="justify"><span style="color:#0000ff;">dijit.dijit</span> (layouts dojo)</p>
</li>
<li>
<p class="western" style="margin-bottom:0;" align="justify"><span style="color:#0000ff;">dijit.form.Button</span> (widget button)</p>
</li>
<li>
<p class="western" style="margin-bottom:0;" align="justify"><span style="color:#0000ff;">dojo.parser </span>(farejador que procura widgets no meio do 	HTML para ativar)</p>
</li>
<li>
<p class="western" style="margin-bottom:0;" align="justify"><span style="color:#0000ff;">xhrPost </span>(Api 	dojo para envio de dados via Ajax pelo método Post)</p>
</li>
<li>
<p class="western" style="margin-bottom:0;" align="justify"><span style="color:#0000ff;">tundra.css</span> (folha 	padrão da biblioteca dojo)</p>
</li>
<li>
<p class="western" style="margin-bottom:0;" align="justify">classe 	de conversão Json PHP (já 	vem de brinde com o Dojo)</p>
</li>
<li>
<p class="western" style="margin-bottom:0;" align="justify">alguns 	scripts adicionais pra organizar as coisas</p>
</li>
</ol>
<p class="western" style="margin-bottom:0;" align="justify">
<p class="western" style="margin-bottom:0;" align="justify">
<p class="western" style="margin-bottom:0;" align="justify"><span style="color:#000000;"><span style="font-family:Verdana,sans-serif;"><span style="font-size:small;"><strong>Mãos á obra:</strong></span></span></span></p>
<p class="western" style="margin-bottom:0;" align="justify">Nosso maior trabalho será com o arquivo index.php no qual precisamos adicionar as devidas funcionalidades do dojo.</p>
<p class="western" style="margin-bottom:0;" align="justify">Abaixo o código de index.php, desculpem a endentação que não é das melhores, por que foi adequada à largura disponível de área para textos do blog.</p>
<p class="western" style="margin-bottom:0;" align="left"><span style="color:#000000;"><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;"><span style="color:#0000ff;">&#60;?</span><span style="color:#a31515;">php<br />
</span></span></span></span><span style="color:#3e3e3e;"><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;">//charset<br />
</span></span></span><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;"><span style="color:#000000;">header</span><span style="color:#000099;">(</span><span style="color:#cc0000;">&#8220;Content-Type: text/html; charset=ISO-8859-1&#8243;</span><span style="color:#0000ff;">,</span><span style="color:#006600;">true</span><span style="color:#000099;">)</span><span style="color:#000000;">;</span> </span></span></p>
<p class="western" style="margin-bottom:0;" align="left">
<p class="western" style="margin-bottom:0;" align="left"><span style="color:#3e3e3e;"><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;">//modifique aqui o caminho da url do dojo<br />
//em seu servidor<br />
</span></span></span><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;"><span style="color:#464600;"><strong>$DOJO_URL</strong></span><span style="color:#0000ff;">=</span><span style="color:#cc0000;">&#8220;http://localhost/dojo-release-1.3.0-src/&#8221;</span><span style="color:#000000;">;</span></span></span></p>
<p class="western" style="margin-bottom:0;" align="left"><span style="color:#0000ff;"><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;">?&#62;</span></span></span><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;"><span style="color:#0000ff;"><br />
&#60;</span><span style="color:#a31515;">html</span> <span style="color:#ff0000;">xmlns</span><span style="color:#000000;">=</span><span style="color:#0000ff;">&#8220;http://www.w3.org/1999/xhtml&#8221;&#62;<br />
&#60;</span><span style="color:#a31515;">head</span><span style="color:#0000ff;">&#62;<br />
</span><span style="color:#ffffff;">_</span><span style="color:#0000ff;">&#60;</span><span style="color:#a31515;">title</span><span style="color:#0000ff;">&#62;</span><span style="color:#000000;">TESTE xhrPost</span><span style="color:#0000ff;">&#60;/</span><span style="color:#a31515;">title</span><span style="color:#0000ff;">&#62;<br />
</span><span style="color:#ffffff;">_</span><span style="color:#0000ff;">&#60;</span><span style="color:#a31515;">link<br />
</span><span style="color:#ffffff;">__</span><span style="color:#ff0000;">id</span><span style="color:#000000;">=</span><span style="color:#0000ff;">&#8220;themeStyles&#8221;<br />
</span><span style="color:#ffffff;">__</span><span style="color:#ff0000;">rel</span><span style="color:#000000;">=</span><span style="color:#0000ff;">&#8220;stylesheet&#8221;<br />
</span><span style="color:#ffffff;">__</span><span style="color:#ff0000;">href</span><span style="color:#000000;">=</span><span style="color:#0000ff;">&#8220;&#60;?=$DOJO_URL;?&#62;dijit/themes/tundra/tundra.css&#8221;&#62;<br />
</span><span style="color:#ffffff;">_</span><span style="color:#0000ff;">&#60;</span><span style="color:#a31515;">script</span> <span style="color:#ff0000;">type</span><span style="color:#000000;">=</span><span style="color:#0000ff;">&#8220;text/javascript&#8221;<br />
</span><span style="color:#ffffff;">_________</span><span style="color:#ff0000;">src</span><span style="color:#000000;">=</span><span style="color:#0000ff;">&#8220;&#60;?=$DOJO_URL; ?&#62;dojo/dojo.js&#8221;<br />
</span><span style="color:#ffffff;">_________</span><span style="color:#ff0000;">djConfig</span><span style="color:#000000;">=</span><span style="color:#0000ff;">&#8220;isDebug:false, parseOnLoad: true&#8221;<br />
</span><span style="color:#ffffff;">_________</span><span style="color:#ff0000;">charset</span><span style="color:#000000;">=</span><span style="color:#0000ff;">&#8220;utf-8&#8243;&#62;&#60;/</span><span style="color:#a31515;">script</span><span style="color:#0000ff;">&#62;<br />
</span><span style="color:#ffffff;">_</span><span style="color:#0000ff;">&#60;</span><span style="color:#a31515;">script</span> <span style="color:#ff0000;">type</span><span style="color:#000000;">=</span><span style="color:#0000ff;">&#8220;text/javascript&#8221;</span> <span style="color:#ff0000;">charset</span><span style="color:#000000;">=</span><span style="color:#0000ff;">&#8220;utf-8&#8243;&#62;</span></span></span></p>
<p class="western" style="margin-bottom:0;" align="left"><span style="color:#008000;"><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;"><span style="color:#ffffff;">__</span>//carrega layer  dijit para interfaces<br />
</span></span></span><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;"><span style="color:#ffffff;">__</span><span style="color:#000000;">dojo</span><span style="color:#5c5c5c;">.</span><span style="color:#000000;">require</span><span style="color:#5c5c5c;">(</span><span style="color:#005c00;">&#8220;dijit.dijit&#8221;</span><span style="color:#5c5c5c;">);</span> </span></span></p>
<p class="western" style="margin-bottom:0;" align="left"><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;"><span style="color:#ffffff;">__</span><span style="color:#008000;">//botao do dojo p engatilhar o xhrPost<br />
</span><span style="color:#ffffff;">__</span><span style="color:#000000;">dojo</span><span style="color:#5c5c5c;">.</span><span style="color:#000000;">require</span><span style="color:#5c5c5c;">(</span><span style="color:#005c00;">&#8220;dijit.form.Button&#8221;</span><span style="color:#5c5c5c;">);</span><span style="color:#008000;"> </span></span></span></p>
<p class="western" style="margin-bottom:0;" align="left"><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;"><span style="color:#ffffff;">__</span><span style="color:#008000;">//varre o HTML em busca de widgets dojo</span><span style="color:#ffffff;">__<br />
__</span><span style="color:#000000;">dojo</span><span style="color:#5c5c5c;">.</span><span style="color:#000000;">require</span><span style="color:#5c5c5c;">(</span><span style="color:#005c00;">&#8220;dojo.parser&#8221;</span><span style="color:#5c5c5c;">);</span></span></span></p>
<p class="western" style="margin-bottom:0;" align="left"><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;"> </span></span></p>
<p class="western" style="margin-bottom:0;" align="left"><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;"><span style="color:#ffffff;">__</span><span style="color:#008000;">//função [sendForm] para estabelecer o envio<br />
</span><span style="color:#ffffff;">__</span><span style="color:#008000;">//dos dados via xhrPost. Esta função é executada<br />
</span><span style="color:#ffffff;">__</span><span style="color:#008000;">//uma única vez quando a página é carregada, para<br />
</span><span style="color:#ffffff;">__</span><span style="color:#008000;">//que seja estabelecida a comunicação entre o<br />
</span><span style="color:#ffffff;">__</span><span style="color:#008000;">//FORM e o xhrPost, bem como colocar o gatilho<br />
</span><span style="color:#ffffff;">__</span><span style="color:#008000;">//do xhrPost no botão “</span><span style="color:#005c00;">botao_submit_dojo</span><span style="color:#008000;">” que é um<br />
</span><span style="color:#ffffff;">__</span><span style="color:#008000;">//widget Dojo. Não funfa com botões tradicionais.</span></span></span></p>
<p class="western" style="margin-bottom:0;" align="left"><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;"><span style="color:#ffffff;"><strong>__</strong></span><span style="color:#0000c0;"><strong>function</strong></span> <span style="color:#000000;">sendForm</span><span style="color:#5c5c5c;">()</span> <span style="color:#5c5c5c;">{<br />
</span><span style="color:#ffffff;"><strong>___</strong></span><span style="color:#0000c0;"><strong>var</strong></span> <span style="color:#000000;">button</span> <span style="color:#5c5c5c;">=</span> <span style="color:#000000;">dijit</span><span style="color:#5c5c5c;">.</span><span style="color:#000000;">byId</span><span style="color:#5c5c5c;">(</span><span style="color:#005c00;">&#8220;botao_submit_dojo&#8221;</span><span style="color:#5c5c5c;">);<br />
</span><span style="color:#ffffff;">___</span><span style="color:#000000;">dojo</span><span style="color:#5c5c5c;">.</span><span style="color:#000000;">connect</span><span style="color:#5c5c5c;">(<br />
</span><span style="color:#ffffff;">____</span><span style="color:#000000;">button</span><span style="color:#5c5c5c;">,<br />
</span><span style="color:#ffffff;">____</span><span style="color:#005c00;">&#8220;onClick&#8221;</span><span style="color:#5c5c5c;">,<br />
</span><span style="color:#ffffff;"><strong>____</strong></span><span style="color:#0000c0;"><strong>function</strong></span><span style="color:#5c5c5c;">(</span><span style="color:#000000;">event</span><span style="color:#5c5c5c;">){<br />
</span><span style="color:#ffffff;">_____</span><span style="color:#008000;">//para (stop) o evento submit original<br />
</span><span style="color:#ffffff;">_____</span><span style="color:#000000;">event</span><span style="color:#5c5c5c;">.</span><span style="color:#000000;">preventDefault</span><span style="color:#5c5c5c;">();<br />
</span><span style="color:#ffffff;">_____</span><span style="color:#000000;">event</span><span style="color:#5c5c5c;">.</span><span style="color:#000000;">stopPropagation</span><span style="color:#5c5c5c;">();<br />
</span><span style="color:#ffffff;"><strong>_____</strong></span><span style="color:#0000c0;"><strong>var</strong></span> <span style="color:#000000;">deferred</span> <span style="color:#5c5c5c;">=</span> <span style="color:#000000;">dojo</span><span style="color:#5c5c5c;">.</span><span style="color:#000000;">xhrPost</span><span style="color:#5c5c5c;">({<br />
</span></span></span><span style="color:#008000;"><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;"><span style="color:#ffffff;">______</span>//”form_teste” – id do formulário HTML<br />
<span style="color:#ffffff;">______</span>//por este id o dojo localiza o FORM<br />
</span></span></span><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;"><span style="color:#ffffff;">______</span><span style="color:#000000;">form</span><span style="color:#5c5c5c;">:</span> <span style="color:#000000;">dojo</span><span style="color:#5c5c5c;">.</span><span style="color:#000000;">byId</span><span style="color:#5c5c5c;">(</span><span style="color:#005c00;">&#8220;form_teste&#8221;</span><span style="color:#5c5c5c;">),<br />
</span><span style="color:#ffffff;">______</span><span style="color:#000000;">handleAs</span><span style="color:#5c5c5c;">:</span> <span style="color:#005c00;">&#8220;text&#8221;</span><span style="color:#5c5c5c;">,<br />
</span><span style="color:#ffffff;">______</span><span style="color:#000000;">load</span><span style="color:#5c5c5c;">:</span><span style="color:#000000;">resJsonOk</span><span style="color:#5c5c5c;">,<br />
</span><span style="color:#ffffff;">______</span><span style="color:#000000;">error</span><span style="color:#5c5c5c;">:</span><span style="color:#000000;">resJsonError<br />
</span><span style="color:#ffffff;">_____</span><span style="color:#5c5c5c;">});</span><span style="color:#008000;">//xhrPost<br />
</span><span style="color:#ffffff;">____</span><span style="color:#5c5c5c;">});</span><span style="color:#008000;">//function(event)<br />
</span><span style="color:#ffffff;">__</span><span style="color:#5c5c5c;">}</span><span style="color:#008000;">//function sendForm()</span></span></span></p>
<p class="western" style="margin-bottom:0;" align="left">
<p class="western" style="margin-bottom:0;" align="left"><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;"> </span></span></p>
<p class="western" style="margin-bottom:0;" align="left"><span style="color:#008000;"><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;"><span style="color:#ffffff;">__</span>//mensagem erro de comunicação com o servidor<br />
</span></span></span><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;"><span style="color:#ffffff;"><strong>__</strong></span><span style="color:#0000c0;"><strong>function</strong></span><span style="color:#5c5c5c;"> </span><span style="color:#000000;">resJsonError</span><span style="color:#5c5c5c;">(</span><span style="color:#000000;">data</span><span style="color:#5c5c5c;">,</span><span style="color:#000000;">ioArgs</span><span style="color:#5c5c5c;">){<br />
</span><span style="color:#ffffff;"><strong>___</strong></span><span style="color:#0000c0;"><strong>var</strong></span> <span style="color:#000000;">msg</span> <span style="color:#5c5c5c;">=</span> <span style="color:#005c00;">&#8216;Nenhuma resposta do servidor.&#8217;</span><span style="color:#5c5c5c;">;<br />
</span><span style="color:#ffffff;"><strong>___</strong></span><span style="color:#0000c0;"><strong>if</strong></span><span style="color:#5c5c5c;">(</span><span style="color:#000000;">data</span><span style="color:#5c5c5c;">)<br />
</span><span style="color:#ffffff;">____</span><span style="color:#000000;">msg</span> <span style="color:#5c5c5c;">+=</span> <span style="color:#005c00;">&#8216;Ocorreram os seguintes erros em &#8216;</span><span style="color:#5c5c5c;">;<br />
</span><span style="color:#ffffff;">____</span><span style="color:#000000;">msg</span> <span style="color:#5c5c5c;">+=</span> <span style="color:#005c00;">&#8216;&#60;b&#62;recebe_dados.php:&#60;/b&#62;&#60;br&#62; &#8216;</span> <span style="color:#5c5c5c;">+</span> <span style="color:#000000;">data</span><span style="color:#5c5c5c;">;<br />
</span><span style="color:#ffffff;">___</span><span style="color:#000000;">dojo</span><span style="color:#5c5c5c;">.</span><span style="color:#000000;">byId</span><span style="color:#5c5c5c;">(</span><span style="color:#005c00;">&#8220;ct_msgs&#8221;</span><span style="color:#5c5c5c;">).</span><span style="color:#000000;">innerHTML</span> <span style="color:#5c5c5c;">=</span> <span style="color:#000000;">msg</span><span style="color:#5c5c5c;">;</span></span></span></p>
<p class="western" style="margin-bottom:0;" align="left">
<p class="western" style="margin-bottom:0;" align="left"><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;"><span style="color:#ffffff;">__</span><span style="color:#5c5c5c;">}</span><span style="color:#008000;">//function resJsonError(&#8230;)<br />
</span></span></span><span style="color:#008000;"><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;"><span style="color:#ffffff;">__</span>//recepção da MSG de retorno OK, recebe o conteúdo<br />
</span></span></span><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;"><span style="color:#ffffff;">__</span><span style="color:#008000;">//JSON devolvido do recebe_dados.php, e extrai as<br />
</span><span style="color:#ffffff;">__</span><span style="color:#008000;">//variáveis (status e msg) com seus respectivos valores</span></span></span></p>
<p class="western" style="margin-bottom:0;" align="left">
<p class="western" style="margin-bottom:0;" align="left"><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;"><span style="color:#ffffff;"><strong>__</strong></span><span style="color:#0000c0;"><strong>function</strong></span><span style="color:#5c5c5c;"> </span><span style="color:#000000;">resJsonOk</span><span style="color:#5c5c5c;">(</span><span style="color:#000000;">data</span><span style="color:#5c5c5c;">,</span><span style="color:#000000;">ioArgs</span><span style="color:#5c5c5c;">) {<br />
</span><span style="color:#ffffff;"><strong>___</strong></span><span style="color:#0000c0;"><strong>if</strong></span><span style="color:#5c5c5c;">(</span><span style="color:#000000;">data</span><span style="color:#5c5c5c;">){<br />
</span><span style="color:#ffffff;"><strong>____</strong></span><span style="color:#0000c0;"><strong>var</strong></span> <span style="color:#000000;">d</span> <span style="color:#5c5c5c;">=</span> <span style="color:#000000;">dojo</span><span style="color:#5c5c5c;">.</span><span style="color:#000000;">fromJson</span><span style="color:#5c5c5c;">(</span><span style="color:#000000;">data</span><span style="color:#5c5c5c;">),<br />
</span><span style="color:#ffffff;">____</span><span style="color:#000000;">conteudo_msg</span> <span style="color:#5c5c5c;">=</span> <span style="color:#005c00;">&#8220;STATUS: ["</span><span style="color:#5c5c5c;">+</span><span style="color:#000000;">d</span><span style="color:#5c5c5c;">.</span><span style="color:#000000;">status</span><span style="color:#5c5c5c;">+</span><span style="color:#005c00;">"] &#60;br&#62;&#8221;</span><span style="color:#5c5c5c;">;<br />
</span><span style="color:#ffffff;">____</span><span style="color:#000000;">conteudo_msg</span> <span style="color:#5c5c5c;">+=</span> <span style="color:#000000;">d</span><span style="color:#5c5c5c;">.</span><span style="color:#000000;">msg</span> <span style="color:#5c5c5c;">+</span> <span style="color:#005c00;">&#8220;&#60;br&#62;&#8221;</span><span style="color:#5c5c5c;">;<br />
</span><span style="color:#ffffff;">____</span><span style="color:#000000;">dojo</span><span style="color:#5c5c5c;">.</span><span style="color:#000000;">byId</span><span style="color:#5c5c5c;">(</span><span style="color:#005c00;">&#8220;ct_msgs&#8221;</span><span style="color:#5c5c5c;">).</span><span style="color:#000000;">innerHTML</span> <span style="color:#5c5c5c;">=</span> <span style="color:#000000;">conteudo_msg</span><span style="color:#5c5c5c;">;<br />
</span><span style="color:#ffffff;">___</span><span style="color:#5c5c5c;">}</span><span style="color:#008000;">//if<br />
</span><span style="color:#ffffff;">__</span><span style="color:#5c5c5c;">}</span><span style="color:#008000;">//function resJsonOk(&#8230;)</span></span></span></p>
<p class="western" style="margin-bottom:0;" align="left">
<p class="western" style="margin-bottom:0;" align="left"><span style="color:#ffffff;">__</span><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;"><span style="color:#008000;">//executa sendForm quando a página for carregada<br />
</span></span></span><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;"><span style="color:#ffffff;">___</span><span style="color:#000000;">dojo.addOnLoad(sendForm);<br />
</span><span style="color:#ffffff;">_</span><span style="color:#0000ff;">&#60;/</span><span style="color:#a31515;">script</span><span style="color:#0000ff;">&#62;<br />
&#60;/</span><span style="color:#a31515;">head</span><span style="color:#0000ff;">&#62;<br />
&#60;</span><span style="color:#a31515;">body</span> <span style="color:#ff0000;">class</span><span style="color:#000000;">=</span><span style="color:#0000ff;">&#8220;tundra&#8221;&#62;<br />
</span><span style="color:#ffffff;">_</span><span style="color:#0000ff;">&#60;</span><span style="color:#a31515;">div</span> <span style="color:#ff0000;">id</span><span style="color:#000000;">=</span><span style="color:#0000ff;">&#8220;ct_msgs&#8221;&#62;&#60;/</span><span style="color:#a31515;">div</span><span style="color:#0000ff;">&#62;<br />
</span><span style="color:#ffffff;">_</span><span style="color:#0000ff;">&#60;</span><span style="color:#a31515;">div</span> <span style="color:#ff0000;">id</span><span style="color:#000000;">=</span><span style="color:#0000ff;">&#8220;ct_geral&#8221;&#62;<br />
</span><span style="color:#ffffff;">__</span><span style="color:#008000;">&#60;!&#8211;Abaixo um formulário simplório com&#8230; &#8211;&#62;<br />
</span><span style="color:#ffffff;">__</span><span style="color:#008000;">&#60;!&#8211;as configurações tradicionais &#8211;&#62;<br />
</span><span style="color:#ffffff;">__</span><span style="color:#0000ff;">&#60;</span><span style="color:#a31515;">form</span> <span style="color:#ff0000;">id</span><span style="color:#000000;">=</span><span style="color:#0000ff;">&#8220;form_teste&#8221;</span> <span style="color:#ff0000;">method</span><span style="color:#000000;">=</span><span style="color:#0000ff;">&#8220;post&#8221;<br />
</span><span style="color:#ffffff;">___</span><span style="color:#ff0000;">action</span><span style="color:#000000;">=</span><span style="color:#0000ff;">&#8220;recebe_dados.php&#8221;&#62;<br />
</span><span style="color:#ffffff;">__ </span><span style="color:#008000;">&#60;!&#8211;Tags de entrada de dados&#8230; &#8211;&#62;<br />
</span><span style="color:#ffffff;">__ </span><span style="color:#008000;">&#60;!&#8211;também tradicionais &#8211;&#62;<br />
</span><span style="color:#ffffff;">___</span><span style="color:#0000ff;">&#60;</span><span style="color:#a31515;">label</span><span style="color:#0000ff;">&#62;</span><span style="color:#000000;">Nome:</span><span style="color:#0000ff;">&#60;/</span><span style="color:#a31515;">label</span><span style="color:#0000ff;">&#62;</span><span style="color:#000000;">&#38;nbsp;<br />
</span><span style="color:#ffffff;">___</span><span style="color:#0000ff;">&#60;</span><span style="color:#a31515;">input</span><span style="color:#ffffff;"> </span><span style="color:#ff0000;">type</span><span style="color:#000000;">=</span><span style="color:#0000ff;">&#8220;text&#8221;</span> <span style="color:#ff0000;">name</span><span style="color:#000000;">=</span><span style="color:#0000ff;">&#8220;txt_nome&#8221;</span> <span style="color:#0000ff;">/&#62;</span><span style="color:#000000;">&#38;nbsp;<br />
</span><span style="color:#ffffff;">___</span><span style="color:#0000ff;">&#60;</span><span style="color:#a31515;">label</span><span style="color:#0000ff;">&#62;</span><span style="color:#000000;">Endere&#38;ccedil;o:</span><span style="color:#0000ff;">&#60;/</span><span style="color:#a31515;">label</span><span style="color:#0000ff;">&#62;</span><span style="color:#000000;">&#38;nbsp;<br />
</span><span style="color:#ffffff;">___</span><span style="color:#0000ff;">&#60;</span><span style="color:#a31515;">input</span> <span style="color:#ff0000;">type</span><span style="color:#000000;">=</span><span style="color:#0000ff;">&#8220;text&#8221;</span> <span style="color:#ff0000;">name</span><span style="color:#000000;">=</span><span style="color:#0000ff;">&#8220;txt_endereco&#8221;</span> <span style="color:#0000ff;">/&#62;</span><span style="color:#000000;">&#38;nbsp;<br />
</span><span style="color:#ffffff;">___</span><span style="color:#008000;">&#60;!&#8211;botão especial, que é um WIDGET dojo &#8211;&#62;<br />
</span><span style="color:#ffffff;">___</span><span style="color:#0000ff;">&#60;</span><span style="color:#a31515;">button</span> <span style="color:#ff0000;">dojoType</span><span style="color:#000000;">=</span><span style="color:#0000ff;">&#8220;dijit.form.Button&#8221;<br />
</span><span style="color:#ffffff;">____</span><span style="color:#ff0000;">id</span><span style="color:#000000;">=</span><span style="color:#0000ff;">&#8220;submitButton&#8221;&#62;</span><span style="color:#000000;">Enviar</span><span style="color:#0000ff;">&#60;/</span><span style="color:#a31515;">button</span><span style="color:#0000ff;">&#62;<br />
</span><span style="color:#ffffff;">__</span><span style="color:#0000ff;">&#60;/</span><span style="color:#a31515;">form</span><span style="color:#0000ff;">&#62;<br />
</span><span style="color:#ffffff;">_</span><span style="color:#0000ff;">&#60;/</span><span style="color:#a31515;">div</span><span style="color:#0000ff;">&#62;<br />
&#60;/</span><span style="color:#a31515;">body</span><span style="color:#0000ff;">&#62;<br />
&#60;/</span><span style="color:#a31515;">html</span><span style="color:#0000ff;">&#62;</span></span></span></p>
<p class="western" style="margin-bottom:0;" align="left">
<p class="western" style="margin-bottom:0;" align="left">
<p class="western" style="margin-bottom:0;" align="left">Abaixo o código para recebe_dados.php que será utilizado em nosso teste. O código está bem comentado, dispensando maiores&#8230; comentários hehehe.</p>
<p class="western" style="margin-bottom:0;" align="left">
<p class="western" style="margin-bottom:0;" align="left"><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;"><span style="color:#0000ff;">&#60;?</span><span style="color:#a31515;">php</span></span></span></p>
<p class="western" style="margin-bottom:0;" align="left"><span style="color:#3e3e3e;"><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;">//endereço dojo no File System</span></span></span><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;"><span style="color:#464600;"><strong><br />
$DFS</strong></span><span style="color:#0000ff;">=</span><span style="color:#cc0000;">&#8220;c:/apache2.2/htdocs/dojo-release-1.3.0-src&#8221;</span><span style="color:#000000;">;</span></span></span></p>
<p class="western" style="margin-bottom:0;" align="left">
<p class="western" style="margin-bottom:0;" align="left"><span style="color:#3e3e3e;"><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;">//classe JSON PHP do dojo</span></span></span><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;"><span style="color:#006600;"><br />
require</span><span style="color:#000099;">(</span><span style="color:#464600;"><strong>$DFS</strong></span><span style="color:#0000ff;">.</span><span style="color:#cc0000;">&#8220;/dojo/tests/resources/JSON.php&#8221;</span><span style="color:#000099;">)</span><span style="color:#000000;">;</span></span></span></p>
<p class="western" style="margin-bottom:0;" align="left"><span style="color:#3e3e3e;"><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;">/*<br />
* Neste espaço poderiam haver tarefas para<br />
* salvar os dados em BD<br />
*<br />
*/</span></span></span></p>
<p class="western" style="margin-bottom:0;" align="left"><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;"><span style="color:#464600;">//monta uma string com os dados recebidos<strong><br />
$dr</strong></span> <span style="color:#0000ff;">=</span><span style="color:#cc0000;">&#8220;Dados recebidos:&#8221;</span><span style="color:#464600;">;<strong><br />
$dr</strong></span><span style="color:#0000ff;">.=</span><span style="color:#cc0000;">&#8221; ['nome': "</span><span style="color:#0000ff;">.</span><span style="color:#000000;">$_POST</span><span style="color:#0000ff;">[</span><span style="color:#cc0000;">"txt_nome"</span><span style="color:#0000ff;">].</span><span style="color:#cc0000;">&#8220;, &#8220;</span><span style="color:#464600;">;<strong><br />
$dr</strong></span><span style="color:#0000ff;">.=</span><span style="color:#cc0000;">&#8220;&#8216;endere&#38;ccedil;o&#8217;: &#8220;</span><span style="color:#0000ff;">.</span><span style="color:#000000;">$_POST</span><span style="color:#0000ff;">[</span><span style="color:#cc0000;">"txt_endereco"</span><span style="color:#0000ff;">]</span><span style="color:#464600;">;<strong><br />
$dr</strong></span><span style="color:#0000ff;">.=</span><span style="color:#cc0000;">&#8220;]&#60;br&#62;&#8221;</span><span style="color:#000000;">;</span></span></span></p>
<p class="western" style="margin-bottom:0;" align="left">
<p class="western" style="margin-bottom:0;" align="left"><span style="color:#3e3e3e;"><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;">//Prepara a resposta de retorno em JSON, para<br />
//cada variável a + adicionar um item no array<br />
//com o nome da variável e seu respectivo valor</span></span></span></p>
<p class="western" style="margin-bottom:0;" align="left"><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;"><span style="color:#464600;"><strong>$ar</strong></span> <span style="color:#0000ff;">=</span> <span style="color:#006600;">array</span><span style="color:#000099;">(</span><span style="color:#cc0000;">&#8217;status&#8217;</span> <span style="color:#0000ff;">=&#62;</span> <span style="color:#cc0000;">&#8220;ok&#8221;</span><span style="color:#0000ff;">,</span><span style="color:#cc0000;"><br />
<span style="color:#ffffff;">____________</span>&#8216;msg&#8217;</span> <span style="color:#0000ff;">=&#62;</span> <span style="color:#464600;"><strong>$dr</strong></span><span style="color:#000099;">)</span><span style="color:#000000;">;</span></span></span></p>
<p class="western" style="margin-bottom:0;" align="left"><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;"> </span></span></p>
<p class="western" style="margin-bottom:0;" align="left"><span style="color:#3e3e3e;"><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;">//cria o objeto manipulador de JSON</span></span></span><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;"><span style="color:#464600;"><strong><br />
$json</strong></span> <span style="color:#0000ff;">=</span> <span style="color:#006600;">new</span> <span style="color:#000000;">Services_JSON</span><span style="color:#000099;">()</span><span style="color:#000000;">;</span></span></span></p>
<p class="western" style="margin-bottom:0;" align="left">
<p class="western" style="margin-bottom:0;" align="left"><span style="color:#3e3e3e;"><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;">//gera uma string com o conteúdo do vetor<br />
//codificado em JSON</span></span></span><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;"><span style="color:#0000ff;"><br />
echo</span> <span style="color:#464600;"><strong>$json</strong></span><span style="color:#0000ff;">-&#62;</span><span style="color:#000000;">encode</span><span style="color:#000099;">(</span><span style="color:#464600;"><strong>$ar</strong></span><span style="color:#000099;">)</span><span style="color:#000000;">;</span></span></span><span style="color:#0000ff;"><span style="font-family:Courier New,monospace;"><span style="font-size:x-small;"><br />
?&#62;</span></span></span></p>
<p class="western" style="margin-bottom:0;" align="left">
<p class="western" style="margin-bottom:0;" align="left">Podemos observar que recebe_dados.php, efetua a simples tarefa de receber os dados enviados, e devolvê-los através de variáveis codificadas em Json. É claro que recebe_dados.php poderia efetuar muitas outras tarefas, como por exemplo: verificar a validade dos dados recebidos, gravá-los no banco de dados, analisar o status da gravação no banco e gerar uma resposta e devolver. Porém vamos primar pela simplicidade por que o foco de nosso estudo é o funcionamento do xhrPost. Uma vez efetuadas as tarefas, o array PHP com as variáveis de resposta é lançado para o método encode do objeto $json, o qual retorna uma string JSON. Sempre que um browser roda um arquivo no servidor, e este possui um echo ou equivalente, uma strig de texto é devolvida para o browser automaticamente, e esta é exibida na tela. Porém em nosso caso o solicitante não foi diretamente o browser, porém o agente xhrPost que o fez enviando dados para o arquivo recebe_dados.php, naturalmente xhrPost aguarda alguma string de retorno vinda deste arquivo, pelo protocolo HTTP (veja novamente a figura 2). Juntando tudo isto, a resposta recebida virá em JSON, como no exemplo abaixo:</p>
<p class="western" style="margin-bottom:0;font-weight:normal;" align="left"><strong>Variáveis:</strong></p>
<p class="western" style="margin-bottom:0;font-weight:normal;" align="left"><span style="color:#0000ff;">“status” = ok,<br />
“msg” = Dados recebidos: ['nome': Leonir, 'endereço': Rua Ah\u002e002e. Programando...!]</span></p>
<p><strong>String Json:</strong></p>
<p class="western" style="margin-bottom:0;font-weight:normal;" align="left"><span style="color:#0000ff;">{&#8220;status&#8221;:&#8221;ok&#8221;,&#8221;msg&#8221;:&#8221;Dados recebidos: ['nome': Leonir, 'endereço': Rua Ah\u002e002e. Programando...!]&#8220;} </span></p>
<p class="western" style="margin-bottom:0;font-weight:normal;" align="left">Salve index.php, e recebe_dados.php na mesma pasta, de forma que vc possa acessar index.php através de seu servidor local. Aí é só colocar para rodar, estes códigos estão funcionando perfeitamente, foram testados, e copiados diretamente do editor PHP e Javascript que utilizo o APTANA.</p>
<p class="western" style="margin-bottom:0;font-weight:normal;" align="left">
<p class="western" style="margin-bottom:0;" align="left"><span style="color:#ff0000;"><strong>Observação Importante:</strong></span> Ao copiar o código, e colar em seu editor substitua todas as aspas redigitando-as, ou através do search replace do editor. Isto devido ao fato que o wordpress substitui as aspas normais por umas mais bonitinhas porém inúteis, os interpretadores de código PHP e Javascript não as reconhecem.</p>
<p class="western" style="margin-bottom:0;font-weight:normal;" align="left">É isto, experimente e deixe seu comentário.</p>
<p class="western" style="margin-bottom:0;font-weight:normal;" align="left">Abraço e até o próximo post.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[CFForm and Javascript not evaluating when using xmlhttprequest]]></title>
<link>http://eileenaw.wordpress.com/2009/04/17/cfform-and-javascript-not-evaluating-when-using-xmlhttprequest/</link>
<pubDate>Fri, 17 Apr 2009 07:26:24 +0000</pubDate>
<dc:creator>eileenaw</dc:creator>
<guid>http://eileenaw.wordpress.com/2009/04/17/cfform-and-javascript-not-evaluating-when-using-xmlhttprequest/</guid>
<description><![CDATA[During all my working years with coldfusion, I have never dealt much with cfform because I thought i]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>During all my working years with coldfusion, I have never dealt much with cfform because I thought it has been hard to integrate javascript functions. cfform is supposed to make our lives easier by generating the javascript that we may want.</p>
<p>Currently, the company is moving into cfform for more convenience. Some colleagues are happy to hear that they are going to do lesser javascript than last time. But none of us are experienced in cfform. We all have to learn from scratch and use cfform.</p>
<p>Cfform suddenly got new problems coming up and we need to spend time to solve one by one to ensure that cfform is working and no other errors coming up. Cfform generates script which contains &#60;!&#8211; &#8211;&#62; which causes problem to our current ajax custom script.</p>
<p>Javascript cannot be evaluated when using xmlhttprequest and innerhtml to load the results, so that&#8217;s why my ex-colleague came up with a script function which will search for the script tags inside the called page and evaluate them. It was cool but it needs to ensure that there is no &#60;!&#8211; &#8211;&#62; tags!</p>
<p>Let me try prototype&#8217;s update function instead of innerhtml because the update function will run the scripts inside. Cool&#8230; let me try and hope it will blow the problem away.</p>
<p>No.. not working.. the update could not work for scripts no matter what haiz&#8230; back to the custom evaluate script function that we have&#8230; now looking for ways to trim off the &#60;!&#8211; and &#8211;&#62; from the scripts. Managed to remove &#60;!&#8211; and &#8211;&#62; by using substr and replace for extracted scripts.</p>
<p>Url: <a href="http://www.webdeveloper.com/forum/showthread.php?t=136331">http://www.webdeveloper.com/forum/showthread.php?t=136331</a><br />
Url: <a href="http://www.simpltry.com/2006/11/04/goodbye-innerhtml-hello-update/">http://www.simpltry.com/2006/11/04/goodbye-innerhtml-hello-update/</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Firefox 2.0 – InnerHTML issue]]></title>
<link>http://malakablog.wordpress.com/2008/12/04/firefox-20-%e2%80%93-innerhtml-issue/</link>
<pubDate>Thu, 04 Dec 2008 09:37:47 +0000</pubDate>
<dc:creator>malakablog</dc:creator>
<guid>http://malakablog.wordpress.com/2008/12/04/firefox-20-%e2%80%93-innerhtml-issue/</guid>
<description><![CDATA[Sorry about the long time between posts. Hope to start posting again soon   Anyhow,   I was working ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;">Sorry about the long time between posts. Hope to start posting again soon</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;">Anyhow,</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;">I was working on a web application that is updating the details of a &#60;map&#62; HTML element using the innerHTML, the new innerHTML value is being processed in the server side using AJAX function</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;">I was using the following JavaScript function to do that</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;"> </span></p>
<blockquote>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:blue;font-family:Verdana;">function</span><span style="font-size:10pt;font-family:Verdana;"> jvUpdateImageMap(ImageMapHTML)<span>  </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;">{</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;"><span>    </span><span style="color:blue;">try</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;"><span>    </span>{</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;"><span>          </span>document.getElementById(<span style="color:maroon;">&#8220;MyImageMap&#8221;</span>).innerHTML= ImageMapHTML;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;"><span>         </span><span>  </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;"><span>     </span>}</span></p>
<p class="MsoNormal" style="text-indent:36pt;margin:0;"><span style="font-size:10pt;color:blue;font-family:Verdana;">catch</span><span style="font-size:10pt;font-family:Verdana;">(err)</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;"><span>          </span>{</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;"><span>      </span><span>    </span>}</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;"><span>          </span><span style="color:blue;">finally</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;"><span>          </span>{</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;"><span>          </span>}</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;">}</span></p>
</blockquote>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;">That was working fine for all the browser including Firefox 3.0 but not for Firefox 2.0 </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;">After debugging this I found that for FireFox 3.0 the result of updating the InnerHTML is this </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;"> </span></p>
<blockquote>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:&#34;"><span>  </span></span><span style="font-size:10pt;color:blue;font-family:Verdana;">&#60;</span><span style="font-size:10pt;color:maroon;font-family:Verdana;">map</span><span style="font-size:10pt;font-family:Verdana;"> <span style="color:red;">id</span><span style="color:blue;">=&#8221;MyImageMap&#8221;</span> <span style="color:blue;">&#62;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;"><span>          </span><span style="color:blue;">&#60;</span><span style="color:maroon;">area</span> <span style="color:red;">SHAPE</span><span style="color:blue;">=&#8221;rect&#8221;</span> <span style="color:red;">id</span><span style="color:blue;">=&#8221;0_30&#8243;</span> <span style="color:red;">usemap</span><span style="color:blue;">=&#8221;MyImageMap&#8221;</span> <span style="color:red;">Border</span><span style="color:blue;">=&#8221;0&#8243;</span> <span style="color:red;">href</span><span style="color:blue;">=&#8221;#&#8221;</span> <span style="color:red;">COORDS</span><span style="color:blue;">=&#8221;538,420,550,408&#8243;</span> <span style="color:blue;">/&#62;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;"><span> </span></span><span style="font-size:10pt;color:blue;font-family:Verdana;">&#60;/</span><span style="font-size:10pt;color:maroon;font-family:Verdana;">map</span><span style="font-size:10pt;color:blue;font-family:Verdana;">&#62;</span></p>
</blockquote>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;">This is the correct expected result</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;">But for FIreFox 2.0 the result was this</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;"> </span></p>
<blockquote>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:blue;font-family:Verdana;">&#60;</span><span style="font-size:10pt;color:maroon;font-family:Verdana;">map</span><span style="font-size:10pt;font-family:Verdana;"> <span style="color:red;">id</span><span style="color:blue;">=&#8221;MyImageMap&#8221;</span> <span style="color:blue;">&#62;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:blue;font-family:Verdana;">&#60;</span><span style="font-size:10pt;color:maroon;font-family:Verdana;">map</span><span style="font-size:10pt;font-family:Verdana;"> <span style="color:red;">id</span><span style="color:blue;">=&#8221;MyImageMap&#8221;</span> <span style="color:blue;">&#62;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;"><span>          </span><span style="color:blue;">&#60;</span><span style="color:maroon;">area</span> <span style="color:red;">SHAPE</span><span style="color:blue;">=&#8221;rect&#8221;</span> <span style="color:red;">id</span><span style="color:blue;">=&#8221;0_30&#8243;</span> <span style="color:red;">usemap</span><span style="color:blue;">=&#8221;MyImageMap&#8221;</span> <span style="color:red;">Border</span><span style="color:blue;">=&#8221;0&#8243;</span> <span style="color:red;">href</span><span style="color:blue;">=&#8221;#&#8221;</span> <span style="color:red;">COORDS</span><span style="color:blue;">=&#8221;538,420,550,408&#8243;</span> <span style="color:blue;">/&#62;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:blue;font-family:Verdana;">&#60;/</span><span style="font-size:10pt;color:maroon;font-family:Verdana;">map</span><span style="font-size:10pt;color:blue;font-family:Verdana;">&#62;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:blue;font-family:Verdana;">&#60;/</span><span style="font-size:10pt;color:maroon;font-family:Verdana;">map</span><span style="font-size:10pt;color:blue;font-family:Verdana;">&#62;</span></p>
</blockquote>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;">So to fix this I had to add those lines to the server side function that generate the new &#60;map&#62; HTML code</span><span style="font-size:10pt;font-family:Verdana;"> </span><span style="font-size:10pt;font-family:Verdana;"> </span></p>
<blockquote>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:blue;font-family:Verdana;">If</span><span style="font-size:10pt;font-family:Verdana;"> Context.Request.Browser.Browser = <span style="color:maroon;">&#8220;Firefox&#8221;</span> <span style="color:blue;">Then</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;"><span>       </span><span style="color:blue;">If</span> Context.Request.Browser.MajorVersion = <span style="color:maroon;">&#8220;2&#8243;</span> <span style="color:blue;">Then</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;"><span>    </span><span>           </span>ImageMapHTML = ImageMapHTML.Replace(<span style="color:maroon;">&#8220;&#60;map id=&#8221;"MyImageMap&#8221;" &#62;&#8221;</span>, <span style="color:maroon;">&#8220;&#8221;</span>)</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;"><span>                </span>ImageMapHTML = ImageMapHTML.Replace(<span style="color:maroon;">&#8220;&#60;/map&#62;&#8221;</span>, <span style="color:maroon;">&#8220;&#8221;</span>)</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;"><span>        </span><span style="color:blue;">End</span> <span style="color:blue;">If</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:blue;font-family:Verdana;">End</span><span style="font-size:10pt;font-family:Verdana;"> <span style="color:blue;">If</span></span></p>
</blockquote>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Verdana;"> </span></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[PHP - DOM and InnerHTML]]></title>
<link>http://d34thsp1k3.wordpress.com/2008/11/26/php-dom-and-innerhtml/</link>
<pubDate>Wed, 26 Nov 2008 10:17:29 +0000</pubDate>
<dc:creator>Deathspike</dc:creator>
<guid>http://d34thsp1k3.wordpress.com/2008/11/26/php-dom-and-innerhtml/</guid>
<description><![CDATA[For those who are working with multiple programming or scripting languages, the differences between ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>For those who are working with multiple programming or scripting languages, the differences between them can be frustrating at times. One of the main concerns when comparing PHP to JavaScript is the interaction with the DOM. We can also see that PHP actually <em>does</em> support DOM functionality, however the documentation isn&#8217;t all that specific and we are mostly left to interpertation of which API does what. The most noteable loss was the absence of the famous (or infamous, depending on the developers views) innerHTML.<!--more-->Since the DOM handle functions are all neatly organized in classes, we can create our own classes on top of them and extend the possibilities of the original classes. My intention was to actually &#8220;intercept&#8221; the DOMDocument function getElementById which usually returns a DOMElement. See the following code snippet&#8230;</p>
<pre><code>	class __DOMDocument extends DOMDocument
	{
		public function getElementById( $zName )
		{
			return new __DOMElement( $this, parent::getElementById( $zName ));
		}
	}</code></pre>
<p>Notice how the new DOMElement is created. This is not the default one, this is a custom implementation of such &#8211; hence the prefixed name (__DOMElement). For convenience inside this new class, we also pass the pointer to the DOMDocument containing this element. Now, all we need to do is actually create the functions to parse the innerHTML! The code snippet is as followed&#8230;</p>
<pre><code>	class __DOMElement /*extends DOMElement*/
	{
		private $pDocument;
		private $pElement;

		public function __construct( $pDocument, $pElement )
		{
			$this-&#62;pDocument = $pDocument;
			$this-&#62;pElement = $pElement;
		}

		public function __call( $zFunction, $aArguments )
		{
			if ( is_callable( array( $this-&#62;pElement, $zFunction )))
			{
				return call_user_func_array( array( $this-&#62;pElement, $zFunction ), $aArguments );
			}
		}

		public function __get( $zKey )
		{
			if ( $zKey == "innerHTML" )
			{
				return $this-&#62;getInnerHTML();
			}

			return false;
		}

		public function __set( $zKey, $zValue )
		{
			if ( $zKey == "innerHTML" )
			{
				$this-&#62;flushChilderen();
				$this-&#62;setInnerHTML( $zValue );
				return true;
			}

			return false;
		}

		public function flushChilderen()
		{
			if ( $this-&#62;pElement-&#62;hasChildNodes())
			{
				for ( $i = 0; $i &#60;  $this-&#62;pElement-&#62;childNodes-&#62;length; $i++ )
				{
					 $this-&#62;pElement-&#62;removeChild(  $this-&#62;pElement-&#62;childNodes-&#62;item( $i ));
				}
			}
		}

		public function getInnerHTML()
		{
			@$pObject = new DOMDocument( 1.0, 'UTF8' );
			@$pObject-&#62;appendChild( $pObject-&#62;importNode( $this-&#62;pElement, true ));
			return $pObject-&#62;saveHTML();
		}

		public function setInnerHTML( $zValue )
		{
			@$pObject = new DOMDocument( 1.0, 'UTF8' );
			@$pObject-&#62;loadHTML( $zValue );

			$pAttach = $pObject-&#62;getElementsByTagName( 'body' );

			if ( $pAttach-&#62;length )
			{
				for ( $i = 0; $i &#60; $pAttach-&#62;item( 0 )-&#62;childNodes-&#62;length; $i++ )
				{
					$this-&#62;pElement-&#62;appendChild( $this-&#62;pDocument-&#62;importNode( $pAttach-&#62;item( 0 )-&#62;childNodes-&#62;item( $i ), true ));
				}
			}
		}
	}</code></pre>
<p>To walk you through these new functions, i will explain briefly what is doing where, and why. The constructor function accepts the DOMDocument and the real DOMElement for future reference, we will really need these both to simulate the actions of the DOMElement. The next magic function is __call, which will check if the incoming call is something which is call-able inside the DOMElement, and if so will perform the actual call. The following functions, __get and __set are the magic functions to either set or retrieve the innerHTML of the element. These forward the calls to the actual functions which will parse the element childeren.</p>
<p>The function &#8220;flushChilderen&#8221; is an utility function, which will make sure the element will have no more childeren attached. We will need this when we are setting the new innerHTML, otherwise we&#8217;d get an append effect instead &#8211; we do not want that. The getInnerHTML retrieves the innerHTML in a really simple fashion, a new DOMDocument is created and this node is imported &#8211; after which we simply have to save the HTML and we will have all the childerens HTML! Now that was easy, the last function is the most complicated function (its not that hard, anyway).</p>
<p>This function is &#8220;setInnerHTML&#8221;, where we will also create a new DOMDocument and load up the parsed HTML. This one will automatically generate the body tag because of the loadHTML function, so everything in that is what we have passed to the function. We will retrieve this tag and run through its child elements, which are imported to the real DOMDocument and appended to our element! Thats all there is to it!</p>
<p>I hope this comes in useful!</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Javascript innerTEXT innerHTML]]></title>
<link>http://hoball.wordpress.com/2008/10/31/javascript-innertext-innerhtml/</link>
<pubDate>Fri, 31 Oct 2008 06:26:30 +0000</pubDate>
<dc:creator>hoball</dc:creator>
<guid>http://hoball.wordpress.com/2008/10/31/javascript-innertext-innerhtml/</guid>
<description><![CDATA[一圖勝萬字解釋]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>一圖勝萬字解釋</p>
<p><img class="alignnone size-medium wp-image-230" title="Javascript innerHTML innerTEXT" src="http://hoball.wordpress.com/files/2008/10/200705091026515832.gif?w=300" alt="" width="300" height="99" /></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[innerHTML Flash problem]]></title>
<link>http://mhvyas7.wordpress.com/2008/09/27/innerhtml-flash-problem/</link>
<pubDate>Sat, 27 Sep 2008 17:23:18 +0000</pubDate>
<dc:creator>mhvyas7</dc:creator>
<guid>http://mhvyas7.wordpress.com/2008/09/27/innerhtml-flash-problem/</guid>
<description><![CDATA[Hi,   I have a problem with inner html when i i have a lash object embedded in my html page. When i ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Hi,</p>
<p> </p>
<p>I have a problem with inner html when i i have a lash object embedded in my html page. When i am trying to display a layer with the help of innerhtml then the layer is getting hidden beneath the embedded flash object. can nebdy help me out in sorting this issue???</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Desmistificando o temível AJAX!]]></title>
<link>http://ahaprogramando.wordpress.com/2008/01/27/desmistificando-o-temivel-ajax/</link>
<pubDate>Sun, 27 Jan 2008 20:40:03 +0000</pubDate>
<dc:creator>Leonir Zimmermann</dc:creator>
<guid>http://ahaprogramando.wordpress.com/2008/01/27/desmistificando-o-temivel-ajax/</guid>
<description><![CDATA[O termo AJAX não provém do latim &#8220;Acessarium Javascriptum Atloren Xmelum&#8221;, não, mas da e]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>O termo AJAX não provém do latim &#8220;Acessarium Javascriptum Atloren Xmelum&#8221;, não, mas da expressão da língua inglesa &#8220;Asynchronous JavaScript And XML&#8221; ou Javascript e XML assíncronos.</p>
<p><strong>Um parêntesis teórico:</strong></p>
<p>Esta questão de atividade assíncrona está para Javascript assim com THREAD&#8217;S estão para JAVA. Ou seja, a execução assíncrona ocorre em um tempo diferente da execução do script original. De modo que, se no meio de um looping for chamada a execução de uma tarefa assíncrona, o programa não irá aguardar a conclusão desta tarefa para então passar ao próximo passo do looping. Assim ao concluir a execução de um looping de 10 iterações, em que todas executam uma nova tarefa assíncrona, a nona tarefa pode estar sendo aberta e a primeira não ter sido concluída ainda, mas a terceira tarefa já pode ter retornado um resultado.</p>
<p><strong>O que realmente interessa, prática!<br />
</strong></p>
<p>Vamos partir de um layour HTML ultra básico:</p>
<p>&#60;div id=<span style="color:#0000ff;">&#8220;geral&#8221;</span>&#62;<br />
&#60;div id=<span style="color:#0000ff;">&#8220;coluna_menu&#8221;</span>&#62;&#60;/div&#62;<br />
&#60;div id=<span style="color:#0000ff;">&#8220;coluna_principal&#8221;</span>&#62;&#60;/div&#62;<br />
&#60;/div&#62;</p>
<p>Para incluir dados dinamicamente via PHP poderíamos proceder da maneira tradicional:</p>
<p>&#60;div id=<span style="color:#0000ff;">&#8220;geral&#8221;</span>&#62;<br />
&#60;div id=<span style="color:#0000ff;">&#8220;coluna_menu&#8221;</span>&#62;<br />
&#60;a href=<span style="color:#0000ff;">&#8220;index.php?arquivo=lista.php&#8221;</span>&#62;<br />
&#60;/div&#62;<br />
&#60;div id=<span style="color:#0000ff;">&#8220;coluna_principal&#8221;</span>&#62;<br />
<span style="color:#808080;">&#60;!&#8211; assim ao clicar no menu recarrega a página incluindo o arquivo que deve ser mostrado &#8211;&#62;</span><br />
<span style="color:#ff0000;">&#60;?php</span> include<span style="color:#0000ff;">(</span>$_GET<span style="color:#0000ff;">[</span><span style="color:#ff0000;">'arquivo'</span><span style="color:#0000ff;">])</span>; <span style="color:#ff0000;">?&#62;</span><br />
&#60;/div&#62;<br />
&#60;/div&#62;</p>
<p><strong>Tudo certo até aqui? </strong></p>
<p>Bom, existe uma maneira de se carregar um conteúdo para dentro da div &#8220;coluna_principal&#8221;, sem usar frames ou recarregar a página utilizando includes.</p>
<p>Trata-se da técnica entitulada de AJAX (Asynchronous JavaScript And XML). Serve basicamente para carregar dados (xml, html, texto) em uma página, abrindo um portal no &#8220;espaço tempo&#8221; do browser e indo buscar novo conteúdo no servidor, sem desfazer todo o HTML  que já tinha sido previamente carregado no browser, ao acessar a página.</p>
<p><strong>Um parêntesis de programação javascript:</strong></p>
<p>Em primeiro lugar, gostaria de explicar como funciona o atributo <strong>innerHTML</strong> do javascript. Atenção <strong>innerHTML</strong> não é AJAX. Serve apenas para alterar dinamicamente o HTML contido dentro de uma tag. É preciso ter em mente que o Javascript vê as tags do browser de uma maneira diferente do PHP. Em Javascript, todas as tags HTML podem ser referenciadas como um objeto (com métodos e atributos), ligado ao objeto principal <strong>document</strong>. Em PHP, porém, todas as tag&#8217;s são tratadas puramente como texto, basta fazer <strong>echo</strong> de alguma coisa no meio do html e tá realizado. Claro, isto por que o PHP faz a sua parte lá no servidor, e o servidor apenas tem interesse em fornecer TAG&#8217;s HTML, e não em interpretá-las. Já o Javascript, é  executado no browser, juntamente com o HTML. Logo, estando o HTML interpretado pelo browser, este HTML fica na memória do computador, e o browser não mais o enxerga como um texto, mas como objetos que tem propriedades e comportamentos. Por exemplo, um botão não pode ser visto como um texto, mas deve ser visto como um programa, um objeto que reage ao click do usuário. Continuando:</p>
<p><strong><span style="color:#0000ff;">var</span></strong> container <span style="color:#0000ff;">=</span> document.getElementById(<span style="color:#0000ff;">&#8216;coluna_principal&#8217;</span>);<br />
<span style="color:#808080;">//getElementById localiza um objeto no meio do html,<br />
//pelo seu ID, e retorna uma referência para este objeto.</span></p>
<p>Agora, a variável container se tornou um objeto com referência para a tag &#8220;coluna_principal&#8221;. E ele tem propriedades que podem ser acessadas a partir desta variável. Tipo, poderíamos descobrir que tag é esta:</p>
<p><span style="color:#666699;">alert</span><span style="color:#0000ff;">(</span>container.tagName<span style="color:#0000ff;">)</span>;<span style="color:#808080;"> //isto mostraria &#8220;div&#8221; , pois div é o nome da tag</span></p>
<p><span style="color:#808080;">//que é identificada pelo id &#8220;coluna_principal&#8221;.</span></p>
<p>Aqui é que entra o innerHTML.</p>
<p>container.innerHTML = <span style="color:#0000ff;">&#8220;&#60;br&#62; oi &#60;br&#62;&#60;br&#62;&#60;br&#62;&#60;br&#62; bla bla bla&#8221;</span>;<br />
<span style="color:#808080;"><br />
//com isto o texto e o HTML entre aspas foram adicionados dentro da tag div com id &#8220;coluna_principal&#8221;.</span></p>
<p>Bom esta é a maneira de escrever um HTML novo dentro de uma tag já existente, de forma dinâmica (DHTML &#8211; Dynamic HTML).</p>
<p><strong>Então&#8230; como o Ajax funciona?</strong></p>
<p>Ajax nada mais é do que a técnica para carregar conteúdo no browser, que utiliza funções javascript para buscar dados de um arquivo presente no servidor. Esta tarefa é executada por um componente do browser (<em><span style="color:#0000ff;"><span style="color:#000000;">XMLHttpRequest</span></span></em>), que pode ser acessado através de funções Javascript para buscar no servidor um novo HTML ou XML.</p>
<p><span style="color:#ff0000;">&#60;script&#62;</span><br />
<span style="color:#808080;">//Tenta criar o objeto xmlhttp responsável por buscar os dados no servidor, são necessárias<br />
// 3 tentativas de criação do objeto por conta das discrepâncias de browsers microsoft</span><br />
<span style="color:#0000ff;"><strong>try {<br />
</strong><span style="color:#000000;">xmlhttp</span> =<strong> new</strong> <span style="color:#000000;">XMLHttpRequest</span>();<strong><br />
} catch(ee) {<br />
try{<br />
</strong><span style="color:#000000;">xmlhttp</span> = <strong>new</strong> <span style="color:#000000;">ActiveXObject</span>(&#8220;Msxml2.XMLHTTP&#8221;);<strong><br />
} catch(e) {<br />
try{<br />
</strong><span style="color:#000000;">xmlhttp</span> = <strong>new</strong> <span style="color:#000000;">ActiveXObject</span>(&#8220;Microsoft.XMLHTTP&#8221;);<strong><br />
} catch(E) {<br />
</strong><span style="color:#000000;">xmlhttp</span> = <strong>false</strong>;<strong><br />
}<br />
}<br />
}</strong><br />
</span><br />
<span style="color:#808080;"><br />
//a função de carregamento, recebe como parâmetro<br />
//_idConainer &#8211; id da tag onde será escrito o novo HTML que será buscado no servidor<br />
//_endereco &#8211; endereço da página que será buscada no servidor</span><br />
<strong>function</strong> carrega<span style="color:#000080;">(</span>_idContainer, _endereco<span style="color:#0000ff;">){ </span></p>
<p>xmlhttp.open<span style="color:#0000ff;">(&#8220;GET&#8221;</span>,_endereco,<span style="color:#0000ff;"><strong>true</strong>)</span>;<br />
xmlhttp.onreadystatechange=<strong>function</strong><span style="color:#0000ff;">() {</span></p>
<p><strong><span style="color:#0000ff;">if (</span></strong>xmlhttp.readyState==<span style="color:#ff0000;">4</span><span style="color:#0000ff;"><strong>){ </strong></span></p>
<p><span style="color:#808080;">//pega o resultado e filtra alguns caracteres absurdos</span><br />
retorno=xmlhttp.responseText;<br />
<span style="color:#808080;">//tag_container contem a referencia da tag que vai receber </span><br />
<strong><span style="color:#0000ff;">var</span></strong> tag_container = document.getElementById(_idContainer);<br />
<span style="color:#808080;">//escreve dentro da tag o novo HTML</span><br />
tag_container.innerHTML=retorno; <span style="color:#808080;">//olha o inner html aí</span></p>
<p><strong><span style="color:#0000ff;">}<br />
}</span></strong><br />
<span style="color:#808080;">//Executa</span><br />
xmlhttp.send(<strong>null</strong>)<br />
<strong><span style="color:#0000ff;">}</span></strong><br />
<span style="color:#ff0000;">&#60;/script&#62; </span></p>
<p>Pronto! Lembra daquele trecho básico de html?</p>
<p>&#60;div id=<span style="color:#0000ff;">&#8220;geral&#8221;</span>&#62;<br />
&#60;div id=<span style="color:#0000ff;">&#8220;coluna_menu&#8221;</span>&#62;&#60;/div&#62;<br />
&#60;div id=<span style="color:#0000ff;">&#8220;coluna_principal&#8221;</span>&#62;&#60;/div&#62;<br />
&#60;/div&#62;<br />
Para inserir um conteúdo HTML, no div de id &#8220;coluna_principal&#8221;, basta invocar a função carrega passando como parâmetro o id da div, e o endereço da página que contém os dados que devem ser carregados via AJAX. Ex:</p>
<p><span style="color:#0000ff;">&#60;script&#62;<br />
<span style="color:#000000;">carrega</span>(&#8216;coluna_principal&#8217;, &#8216;dados.php&#8217;);</span></p>
<p><span style="color:#0000ff;"><span style="color:#808080;">// ou se for o caso, a url completa:</span><br />
<span style="color:#000000;">carrega</span>(&#8216;coluna_principal&#8217;, &#8216;http://www.minhapagina.com/dados.php&#8217;);</span><br />
<span style="color:#ff0000;">&#60;/script&#62;<br />
</span></p>
<p>Quando <em>carrega</em> for chamado com os devidos parâmetros é que ocorre a tarefa de carregamento que se dá assincronamente, ou seja, não há como prever o tempo que levará para ela ser concluída, uma vez que este tempo depende de diversos fatores como: a velocidade da conexão de rede naquele momento, a quantidade de dados que serão carregados, a disponibilidade do servidor de atender etc&#8230;</p>
<p><strong>E como fazer para um link ativar o carregamento de uma página usando AJAX?</strong></p>
<p>&#60;div id=<span style="color:#0000ff;">&#8220;geral&#8221;</span>&#62;<br />
&#60;div id=<span style="color:#0000ff;">&#8220;coluna_menu&#8221;</span>&#62;&#60;a href=<span style="color:#0000ff;">&#8220;javascript:carrega(&#8216;coluna_principal&#8217;, &#8216;dados.php&#8217;);&#8221;</span>&#62;acessar dados&#60;/a&#62;&#60;/div&#62;<br />
&#60;div id=<span style="color:#0000ff;">&#8220;coluna_principal&#8221;</span>&#62;&#60;/div&#62;<br />
&#60;/div&#62;<br />
Bom, como podemos ver, AJAX nada mais é do que uma técnica de carregamento de dados. O exemplo acima funciona, porém por tratar-se de um código exemplar de extrema simplicidade, não pode ser utilizado para aplicações sérias. Nele faltam diversos recursos, que talvez em outra análise sobre AJAX possamos aprofundar.</p>
<p><span style="color:#ff0000;"><strong>[15/01/2009 - Edição problema grave no wordpress]  - Ao copiar trechos de código, dos posts do Ahã Programando, substitua todas as aspas redigitando-as. Pois o WordPress substitui as aspas originais por algumas que são inúteis em programação. E os testes acabam não funcionando, deixando os entusiastas da programação web frustrados.  <span style="color:#008000;">Não desista! Tente novamente <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </span></strong></span></p>
<p>Por hoje é só! E como prometido, quero dedicar este pequeno artigo à minha amiga Web Designer Cristina Otto, abração Cris!!</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Get the content of an Iframe in Javascript - crossbrowser solution for both IE and Firefox]]></title>
<link>http://roneiv.wordpress.com/2008/01/18/get-the-content-of-an-iframe-in-javascript-crossbrowser-solution-for-both-ie-and-firefox/</link>
<pubDate>Fri, 18 Jan 2008 17:22:05 +0000</pubDate>
<dc:creator>roneiv</dc:creator>
<guid>http://roneiv.wordpress.com/2008/01/18/get-the-content-of-an-iframe-in-javascript-crossbrowser-solution-for-both-ie-and-firefox/</guid>
<description><![CDATA[Ok, let&#8217;s imagine the use case: I have an iframe somewhere on my page, and when I click a link]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Ok, let&#8217;s imagine the use case: I have an iframe somewhere on my page, and when I click a link or a button I need to get the content of it (could be a textarea e.g.), and then do some stuff with it.</p>
<p>It was easy to do this in IE, but for Firefox I struggled more, as I kept getting the &#8220;frame has no properties&#8221; error message in the console. And when I solved this I couldn&#8217;t get to the content.</p>
<p>There is a lot of references out there claiming that you could use document.frames['nameOfMyIframe'] or window.frames['nameOfMyIframe'] to get the frame, and then use the .innerHTML to get the content, but both are wrong.</p>
<p>I came up with the following function that seems to do the job in both Firefox (tested on version 2.0.0.11 and 3.03 ) and in IE (6 and 7):</p>
<pre class="brush: jscript;">

function getContentFromIframe(iFrameName)
{

    var myIFrame = document.getElementById(iFrameName);
    var content = myIFrame.contentWindow.document.body.innerHTML;

    //Do whatever you need with the content    

}
</pre>
<p>This wasn&#8217;t my biggest contribution, but I spent some time trying to find this solution, and for some of you it might be helpful saving you frome some heavy googling.</p>
<p>Because of some postings about people struggling to get this to work, I now include an example using this script. The example consist of two files, main.html and frame.html. If you want to try it locally, put both of them in the same folder and open main.html.</p>
<p>Main.html:</p>
<pre class="brush: xml;">
&lt;html&gt;
&lt;head&gt;

&lt;/head&gt;
&lt;body&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
function getContentFromIframe(iFrameName)
{

    var myIFrame = document.getElementById(iFrameName);
    var content = myIFrame.contentWindow.document.body.innerHTML;

    alert('content: ' + content);    

    content = 'The inside of my frame has now changed';
    myIFrame.contentWindow.document.body.innerHTML = content;

}

&lt;/script&gt;

&lt;iframe id=&quot;myIframe&quot; src=&quot;frame.html&quot;&gt;

&lt;/iframe&gt;

&lt;a href=&quot;#&quot; onclick=&quot;getContentFromIframe('myIframe')&quot;&gt;Get the content&lt;/a&gt;

&lt;/body&gt;

&lt;/html&gt;
</pre>
<p>Frame.html:</p>
<pre class="brush: xml;">
&lt;html&gt;
&lt;head&gt;

&lt;/head&gt;
&lt;body&gt;

This is inside my frame
&lt;/body&gt;

&lt;/html&gt;
</pre>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[javascript innerHTML not working properly in IE ? ]]></title>
<link>http://shabuz.wordpress.com/2008/01/06/javascript-innerhtml-not-working-properly-in-ie/</link>
<pubDate>Sun, 06 Jan 2008 10:32:49 +0000</pubDate>
<dc:creator>shabuz</dc:creator>
<guid>http://shabuz.wordpress.com/2008/01/06/javascript-innerhtml-not-working-properly-in-ie/</guid>
<description><![CDATA[If its a textarea or textbox then try using innerText instead of innerHTML]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><h4>If its a textarea or textbox then try using innerText instead of innerHTML</h4>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[IE + overflow: hidden + innerHTML == disaster ]]></title>
<link>http://pureform.wordpress.com/2007/12/30/ie-overflow-hidden-innerhtml-disaster/</link>
<pubDate>Mon, 31 Dec 2007 03:49:00 +0000</pubDate>
<dc:creator>pureform</dc:creator>
<guid>http://pureform.wordpress.com/2007/12/30/ie-overflow-hidden-innerhtml-disaster/</guid>
<description><![CDATA[So, once again, IE has tested my patience &#8230; and lost. Here&#8217;s the scoop: I have a div sty]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>So, once again, IE has tested my patience &#8230; and lost.</p>
<p>Here&#8217;s the scoop:</p>
<p>I have a div styled with a width, height and an overflow set to hidden [so it qualifies for IE's oh-so-crucial "hasLayout" attribute]. In essence this div will be populated with content dynamically with JS using the inner HTML property via an ajax call. I have some custom scrollbars I built to scroll the div [hence hiding the overflow content -- therefore hiding and chrome scrollbars] &#8230; Simple enough, right? I&#8217;ve seen this done about a dozen times&#8230;.</p>
<p>This works flawlessly in Firefox [as expected] &#8230; In IE, however, the inner content of the div would spill out into the layout as if it were on a different z-index. I tried manually setting the height and overflow CSS properties every time the script would populate the div, I even went as far as adding the inner content piece by piece [in this case the content is an unsorted list [ul] with one or many [li] children] &#8230; that didn&#8217;t work.</p>
<p>Then I remembered that IE was written by retards and tried something that really makes no sense: <strong>I changed the position to relative</strong>. Now, this property pertains to the element&#8217;s position within the DOM, <em>not</em> how the overflow functions <em>within the element</em>.</p>
<p>So, position == outside, overflow == inside&#8230;..</p>
<p><strong>Me</strong> &#8211; 1<br />
<strong>IE</strong> &#8211; 0</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Too many cooks spoil the DOM (getting content out of page elements)]]></title>
<link>http://jaybyjayfresh.com/2007/09/05/too-many-cooks-spoil-the-dom-getting-content-out-of-page-elements/</link>
<pubDate>Wed, 05 Sep 2007 15:56:42 +0000</pubDate>
<dc:creator>jayfresh</dc:creator>
<guid>http://jaybyjayfresh.com/2007/09/05/too-many-cooks-spoil-the-dom-getting-content-out-of-page-elements/</guid>
<description><![CDATA[I frequently find myself wanting to refer to the contents of an element on a web page, having got ho]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I frequently find myself wanting to refer to the contents of an element on a web page, having got hold of that element in the DOM. However, I equally frequently forget how to access this content.</p>
<p>The confusion arises because there are various ways to get hold of the content of an element: <code>nodeValue</code>, <code>value</code>, <code>data</code>, <code>textContent</code>, <code>innerText</code> and <code>innerHTML</code> all seem to do the job in different circumstances. In the hope that I&#8217;m not the only one with this problem, I looked into the matter&#8230;</p>
<p>In a nutshell:</p>
<ul>
<li><code>nodeValue</code> returns attributes or text (read/write)</li>
<li><code>value</code> returns the text content of an attribute (read)</li>
<li><code>data</code> is used to access text content of a node (read/write)</li>
<li><code>textContent</code> returns the text content of a node and its descendents (read/write)</li>
<li><code>innerText</code> returns the text content of a node and its descendents (read/write)</li>
<li><code>innerHTML</code> returns the HTML contained by an element (read/write)</li>
</ul>
<p><strong><code>nodeValue</code></strong>, counter-intuitively, does not return the text content of a node such as a paragraph i.e. it is not a W3C analogue of <code>innerHTML</code>. <code>nodeValue</code> is in the <a href="http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-F68D080" title="nodeValue in the DOM Core specification" target="_blank">DOM Core specification</a> and is <a href="http://www.quirksmode.org/dom/w3c_core.html#nodeinformation" title="nodeValue on quirksmode.org">well supported</a> by browers. It is a read/write attribute.</p>
<p>This table from <a href="http://developer.mozilla.org/en/docs/DOM:element.nodeValue" title="Mozilla developer pages" target="_blank">developer.mozilla.org</a> shows the return value of accessing nodeValue on various nodes:</p>
<table cellpadding="1" cellspacing="1">
<tr style="background-color:#55bbff;">
<td>Attr</td>
<td>value of attribute</td>
</tr>
<tr style="background-color:#55bbff;">
<td>CDATASection</td>
<td>content of the CDATA Section</td>
</tr>
<tr style="background-color:#55bbff;">
<td>Comment</td>
<td>content of the comment</td>
</tr>
<tr style="background-color:#55bbff;">
<td>Document</td>
<td>null</td>
</tr>
<tr style="background-color:#55bbff;">
<td>DocumentFragment</td>
<td>null</td>
</tr>
<tr style="background-color:#55bbff;">
<td>DocumentType</td>
<td>null</td>
</tr>
<tr style="background-color:#55bbff;">
<td>Element</td>
<td>null </td>
</tr>
<tr style="background-color:#55bbff;">
<td>NamedNodeMap</td>
<td>null</td>
</tr>
<tr style="background-color:#55bbff;">
<td>EntityReference</td>
<td>null </td>
</tr>
<tr style="background-color:#55bbff;">
<td>Notation</td>
<td>null </td>
</tr>
<tr style="background-color:#55bbff;">
<td>ProcessingInstruction</td>
<td>entire content excluding the target</td>
</tr>
<tr style="background-color:#55bbff;">
<td>Text</td>
<td>content of the text node</td>
</tr>
</table>
<p><strong><code>value</code></strong> returns the text value of a node&#8217;s attribute. This does not work with text nodes. <code>value</code> is in the <a href="http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-221662474" title="value in the DOM Core Specification" target="_blank">DOM Core Specification</a> and it is <a href="http://www.quirksmode.org/dom/w3c_core.html#attributes" title="value on quirksmode.org" target="_blank">very poorly supported</a> in Windows IE, although Firefox does support it. It is a read-only attribute.</p>
<p><strong><code>data</code></strong> is used to address the content of a text node. It is the same as nodeValue for that node. <code>data</code> is in the <a href="http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-72AB8359" title="data in the DOM Core Specification" target="_blank">DOM Core Specification</a> and it is <a href="http://www.quirksmode.org/dom/w3c_core.html#data" title="data on quirksmode.org">well supported</a> by browsers. It is a read/write attribute.</p>
<p><strong><code>textContent</code></strong>/<strong><code>innerText</code></strong> returns the text contained in a node and its descendants, ignoring any contained tags. Whilst <code>textContent</code> is in the <a href="http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Node3-textContent" title="textContent in the DOM Level 3 Core Specification" target="_blank">DOM Level 3 Core Specification</a> and it is not really supported at all except in Firefox, <code>innerText</code> is <a href="http://www.quirksmode.org/dom/w3c_html.html#all" title="innerText on quirksmode.org" target="_blank">well supported</a> by browsers, the exception being buggy support in Mozilla 1.75. Both are read/write attributes.</p>
<p><strong><code>innerHTML</code></strong> returns the markup contained in a node and its descendants. Whilst <code>innerHTML</code> is not in a W3C specification, most browsers <a href="http://www.quirksmode.org/dom/w3c_html.html#all" title="innerHTML on quirksmode.org" target="_blank">support it</a> and it is often <a href="http://www.quirksmode.org/dom/innerhtml.html" title="DOM vs. innerHTML on quirksmode.org" target="_blank">faster</a> than W3C DOM methods. It is a read/write attribute.</p>
<p>I&#8217;m heavily indebted to <a href="http://www.quirksmode.org" title="quirksmode.org" target="_blank">quirksmode.org</a> and the <a href="http://www.w3.org" title="W3C website" target="_blank">W3C</a> DOM specifications for this information.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Contruindo uma fila de requisições em Ajax]]></title>
<link>http://nodesign.wordpress.com/2006/08/10/contruindo-uma-fila-de-requisicoes-em-ajax/</link>
<pubDate>Thu, 10 Aug 2006 12:43:30 +0000</pubDate>
<dc:creator>nodesign</dc:creator>
<guid>http://nodesign.wordpress.com/2006/08/10/contruindo-uma-fila-de-requisicoes-em-ajax/</guid>
<description><![CDATA[Olá pessoal, Estou passando um passo a passo de como se criar uma fila de requisições e Ajax, pois c]]></description>
<content:encoded><![CDATA[Olá pessoal, Estou passando um passo a passo de como se criar uma fila de requisições e Ajax, pois c]]></content:encoded>
</item>

</channel>
</rss>
