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

161
Views
How can I use document.createElement DOM in node.js?

I'm new in programming and currently learning node.js and express.js

I have a form for user to contact me when submitted it should open windows mail app, in javascript I can just use document.createElement('a')

but when I use it on node.js it says 'document' is not defined or createElement is not a function

I've tried to use jsdom

Here's the js code:

app.post('/contact-me', function(req, res) {
let name = req.body.userName
let email = req.body.userEmail
let phone = req.body.userPhoneNumber
let subject = req.body.userSubject
let message = req.body.userMessage
let form = req.body.contact /
let contact = {
    name,
    email,
    phone,
    subject,
    message
}

let openMail = new JSDOM(contact) //I've also tried let openMail = new JSDOM(form)
let myEmail = "dev@mail.com"

let a = openMail.window.document.createElement('a')
a.href = `mailto:${myEmail}?subject=${subject}&body=Hello, my name is ${name}, ${subject}, ${message}`
a.click()
})`

Form opening tag: <form class="form-container" action="/contact" method="POST" name="contact">

But it says:

Error: Not implemented: navigation (except hash changes)
at module.exports (D:\folder\node_modules\jsdom\lib\jsdom\browser\not-implemented.js:9:17)      
at navigateFetch (D:\folder\node_modules\jsdom\lib\jsdom\living\window\navigation.js:77:3)      
at exports.navigate (D:\folder\node_modules\jsdom\lib\jsdom\living\window\navigation.js:55:3)   
at Timeout._onTimeout (D:\folder\node_modules\jsdom\lib\jsdom\living\nodes\HTMLHyperlinkElementUtils-impl.js:81:7)
at listOnTimeout (node:internal/timers:559:17)
at processTimers (node:internal/timers:502:7) undefined

Do node.js have different code or I have to do something before using DOM?

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!