Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

254
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda