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

79
Views
Almacenamiento de opciones predeterminadas en una extensión de Chrome

Recibo un error al intentar acceder a las variables de opciones almacenadas por primera vez después de la instalación, tanto en los scripts de contenido como en un trabajador de servicio: Uncaught (in promise) undefined

Aquí está el código que gestiona las opciones de usuario:

 function save_options() { var mykeySetting = document.getElementById('mycheckbox').checked; chrome.storage.sync.set({ mykey: mykeySetting }, function() { // Update status to let user know options were saved. var status = document.getElementById('status'); status.textContent = 'Options saved.'; setTimeout(function() { status.textContent = ''; }, 750); }); } function restore_options() { chrome.storage.sync.get({ mykey: true }, function(items) { document.getElementById('mycheckbox').checked = items.mykey; }); } document.addEventListener('onInstalled', restore_options); document.addEventListener('DOMContentLoaded', restore_options); document.getElementById('save').addEventListener('onInstalled', save_options); document.getElementById('save').addEventListener('click', save_options);
 <!DOCTYPE html> <html> <head> <title>My add-on</title> </head> <link rel="stylesheet" href="options.css" /> <body> <label> <input type="checkbox" id="mycheckbox"> Option 1 </label> <div id="status"></div> <br> <button id="save">Save</button> <script src="options.js"></script> </body> </html>

Después de presionar el botón Guardar en el diálogo de opciones, los errores desaparecen, incluso si vuelvo a cargar la extensión . En otras palabras, los errores aparecen solo después de cargar la extensión por primera vez, hasta presionar el botón Guardar.

about 4 years ago · Santiago Trujillo
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!