writeln is obsolete in Javascript or not?

Asked

Viewed 67 times

-2

I have a simple code example

<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>teste</title>
</head>
<body>

<script>

var nome = "maria";
var sobrenome = "cardozo";
var nome2 = "pedro";
var sobrenome2 = "silva";

// Usando com write
document.write(nome);
document.write(sobrenome);

// Usando com writeln
document.writeln(nome2);
document.writeln(sobrenome2);

</script>

</body>
</html>

NOTE that was for the writeln break the line. No more, it works as if I had put as write to stay only on one line this method is obsolete?

  • Have a look https://answall.com/questions/121598/document-writeln-est%C3%A1-in-disuse-javascript

  • No, this function is not in disuse, you can check it in the documentation of Mozilla firefox

1 answer

-1

I added the "pre" tag and it worked.

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>teste</title>
</head>
<body>
<pre>
<script>

var nome = "maria";
var sobrenome = "cardozo";
var nome2 = "pedro";
var sobrenome2 = "silva";

// Usando com write
document.write(nome);
document.write(sobrenome);

// Usando com writeln
document.writeln(nome2);
document.writeln(sobrenome2);

</script>
<pre>
</body>
</html>

Browser other questions tagged

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