Console shows javascript log very fast and not time view output

Asked

Viewed 196 times

1

This is my code is a simple form:

<!DOCTYPE html>
<html>

<head>
    <title>Formulário</title>
    <meta charset="utf-8" />
</head>

<body>
    <form name="meu_form">

        <h1>Formulário</h1>

        <p class="nome">
            <label for="nome">Nome</label>
            <input type="text" id="nomeid" required="required" name="nome" />
        </p>

        <p class="fone">
            <label for="fone">Fone</label>
            <input type="text" id="foneid" name="fone" />
        </p>
        <p>
            <label for="email">Email</label>
            <input type="email" id="emailid" name="email" />
        </p>
        <p class="submit">
            <input type="submit" onclick="enviar()" value="Enviar" />
        </p>

    </form>
    <script type="text/javascript">
        function enviar() {

            var nome = document.getElementById("nomeid");
            var fone = document.getElementById("foneid");
            var email = document.getElementById("emailid");

            if (nome.value != "") {
               console.log('Obrigado sr(a) ' + nome.value +
                 ' os seus dados foram encaminhados com sucesso.\n'
                 +'Seus dados:\n'
                 +'Nome : '+ nome.value
                 +'\nFone '+ fone.value 
                 +'\nEmail '+ email.value);
            }

        }
    </script>
</body>

</html>

If I replace the console with Alert works, but I want to use the console.

The problem is that when I want to view the output in the browser console Chrome (not tested on others) it is displayed so fast that not time read.

What should I do?

  • why don’t you sweat the Alert?

  • You are using which browser?

1 answer

4


To keep the console on Google Chrome you must follow the following steps:

  • Squeeze F12 on your keyboard to open developer tools.
  • On the tab Console there is a small gear on the right side, click on it.
  • Once done, various settings will appear, check the option Preserve log
  • The island must already be preserved.
  • Thanks great! Very interesting , helped me a lot!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.