Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

366
Visualizações
Uncaught TypeError: document.write(...) is not a function

When using Self-Invoking Functions I got the following error:

Uncaught TypeError: document.write(...) is not a function at index.html:86:29

the entire code:

document.write('<br />')
      //second soloution:
      const anonymousFunc3 = function (x, y) {
        if (x === 'undefined') {
          x = 0 // assign a value to x in case that 'x' is "undefined"
        }
        if (y === 'undefined') {
          y = 0
        }
        return x + y
      }
      document.write(anonymousFunc3())
      document.write('<br />')
      //5
      //this way, the function is executed itself, without any call!

      (function () {
        document.write('Ok!')
        //alert('')
      }
    )()

And here I'm adding a picture of the browser to more clear the problem: enter image description here

Could anyone explain it to me?

I also found that if I place the error-pane code within another <script> tag, the error will be gone! Please take a look at the following codes to more understand:

<script>
.
.
.
</script>
<script>
 (function () {
        document.write('Ok!')
        //alert('')
 })()
</script>


Till now, I don't know the why?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda