Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

218
Vistas
I keep getting a "TypeError: undefined is not an object" error message

I've been trying to make a script to let users install a configuration profile on their iOS or iPadOS devices, and my code is:

function downloadProfile(profileName, configurationProfile) {
    var element = document.createElement("a");
    element.setAttribute("href", "data:application/x-apple-aspen-config," + encodeURIComponent(configurationProfile));
    element.setAttribute("download", profileName + ".mobileconfig");

    element.body.appendChild(element);

    element.click();

    element.body.removeChild();
}

The problem is, I keep getting an error message saying Unhandled Promise Rejection: TypeError: undefined is not an object (evaluating 'element.body.appendChild'). Does anyone know a fix? This is not the entire code of course, it's just the part that I need help with.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The element you create does not have a property body. I assume you want to add the new element to the document, like so instead:

document.body.appendChild(element);

Check you for an example: https://www.w3schools.com/jsref/met_document_createelement.asp

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda