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

142
Views
Obtener currentScript está devolviendo typeError

Estoy tratando de obtener un atributo personalizado que puse en mi etiqueta de secuencia de comandos:

 <script type="text/javascript" src="https://.../mysource.js" customdata="some_value"></script>

Estoy usando el siguiente código para que funcione en IE:

 document.currentScript = document.currentScript || (function () { const field = document.getElementsByTagName('script'); return field[field.length - 1]; })(); // document.currentScript.getAttribute('customdata');

Pero luego recibo el siguiente error cuando intento establecer un nuevo valor en document.currentScript.

TypeError no capturado: no se puede establecer la propiedad currentScript de # <Document> que solo tiene un getter

Solo resuelvo esto cuando estoy usando document.currentScript directamente, pero luego no puedo usarlo en navegadores más antiguos.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Creé otra variable para contener el valor del documento y luego funcionó y no se muestran errores.

about 4 years ago · Juan Pablo Isaza Report

0

Si document.currentScript existe, es una propiedad de solo lectura. Así que solo intente configurarlo si no existe.

 if (!document.currentScript) { document.currentScript = (function() { const field = document.getElementsByTagName('script'); return field[field.length - 1]; })(); }
about 4 years ago · Juan Pablo Isaza Report
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!