Jump to content
Fórum Script Brasil
  • 0

Script De Innerhtml

Jony Walker


Eu tenho este script para fazer aparecer um campo quando o usuário clica "Sim" no botão. Depois o botão vira "Não", e apaga o campo se clicado...

Funciona perfeitamente no IE, mas como posso modificar este script para que o "não" funcione corretamente no FF ??

<script language="javascript">
function muda(){
if (document.srch.botao.value == 'Sim'){
document.getElementById('area').innerHTML = '<span id="bla"><input type="text" name="conven2" size="25" maxlenght="20" id="conven2"></span>';
document.srch.botao.value = 'Não';
document.getElementById('bla').outerHTML = '';
document.srch.botao.value = 'Sim';
<input type="button" class="header" onClick="java script:muda();" value="Sim" id="btn" name="botao"><span id="area"></span>

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Migrate apps from Internet Explorer to Mozilla - MDC

Mozilla supports the legacy methods for adding content into the DOM dynamically, such as document.write, document.open and document.close. Mozilla also supports Internet Explorer's innerHTML method, which it can call on almost any node. It does not, however, support outerHTML (which adds markup around an element, and has no standard equivalent) and innerText (which sets the text value of the node, and which you can achieve in Mozilla by using textContent).

Internet Explorer has several content manipulation methods that are nonstandard and unsupported in Mozilla, including retrieving the value, inserting text and inserting elements adjacent to a node, such as getAdjacentElement and insertAdjacentHTML. Table 3 shows how the W3C standard and Mozilla manipulate content, all of which are methods of any DOM node.

Eu recomendo usar no else o mesmo que usou no if...

document.getElementById('area').innerHTML = ...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Forum Statistics

    • Total Topics
    • Total Posts
  • Create New...