Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

363
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!