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

356
Views
window.print() method throwing error in Firefox Version 100.0 (64-bit)

I have been using the JavaScript print() method for printing the content of a page. The code hasn't been changed in 2 years and it was working on Firefox until a few days ago, when I got the Version 100.0.

This is the code I have been using to print:

print() {
    const printableElement = Printer.createPrintableElement()
    const printableContentWindow = printableElement.contentWindow
    if (!printableContentWindow) {
      return
    }

    const { styles, html } = this.proceedContent()

    printableContentWindow.document.head.innerHTML = `${styles}`
    printableContentWindow.document.body.innerHTML = html

    printableContentWindow.focus()
    printableContentWindow.print()
}

static createPrintableElement() {
    const printableElement = document.createElement('iframe')
    printableElement.width = '0'
    printableElement.height = '0'

    document.body.appendChild(printableElement)

    return printableElement
}

static collectPageStyles() {
    return [...document.querySelectorAll('link[rel="stylesheet"], style')].reduce(
      (acc, style) => (acc += style.outerHTML),
      ''
    )
  }

filterContentElements() {
    const { ignoreElements } = this.options
    const content = this.element

    if (ignoreElements.length === 0) {
      return content
    }

    ignoreElements.forEach((selector) => {
      const elementsToDelete = content.querySelectorAll(selector)
      elementsToDelete.forEach((node) => node.remove())
    })

    return content
}

proceedContent() {
    const styles = Printer.collectPageStyles()
    const html = this.filterContentElements().innerHTML

    return { styles, html }
}

I try to debug it and I realized it fails on the method print(), specifically on printableContentWindow.print(). The error it shows on browser console is this: enter image description here And when it occurs, the page to be printed is completely blank.

This code works perfectly on Chrome, Opera and Opera GX.

Any idea what could be happening?

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!