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

252
Vistas
How to modify an html file with a javascript file?

I'm now to coding so sorry if my question is dumb. I'm trying to code an extension getting information from the html of some websites, and then display the info I got on the popup of the extension. The problem is, when I can't communicate between the foreground.js and the html of the popup. Here is the popup file,

<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>`
    <style>
        body {
            display: flex;
            flex-flow: row wrap;
            justify-content: last baseline;
            align-items: center;
        }
    </style>
</head>

<body>
    <h2>Welcome to LISTOKADO</h2>
    <a href="https://www.listokado.com/" title="lien html">
        <img alt="listokado" src="./logoListo-2.png" width="64" height="64" />
    </a>
    <a>
        <img alt= 'Choisissez un article'id="imgAchatEnCours" src="" width="64" height="64">
    </a>
    <p> <input type="submit" value="Add to wishlist" />
    </p>

    <script src="jquery.js"></script>
    <script type="text/javascript" src="im_achat.js"></script>
</body>

</html>

And here the foreground.js :

console.log(document.getElementsByClassName('a-offscreen')['6'].innerText)
console.log(document.querySelector('#productTitle').textContent)

var img_achat = new Image
img_achat = document.querySelector('#imgTagWrapperId img').src
localStorage.setItem('img_achat_en_cours',img_achat)
console.log('im chargée dans le localstorage')
//document.addEventListener('DOMContentLoaded',() => {
     const recentImageDataUrl = localStorage.getItem("img_achat_en_cours")
     console.log(recentImageDataUrl);

     if(recentImageDataUrl){
      //console.log('test allo')
        Document.getElementById('#imgAchatEnCours').setAttribute("src",recentImageDataUrl)
        console.log('si ça saffiche cest que cest bon');
     }
//});

How can I modify the src of the image 'imgAchatEnCours' in the html of the popup? is there an equivalent to Document.getElementById() like popup.getelement() or something? Because I understood that I'm searching in the web page so I don't modify what i want

Thank you for reading

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