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

237
Visualizações
Put image on first page on the second page javascript

So my problem is that I have two pages products.html and index.html on products.html I have multiple images and a button next to every image and each button corresponds to each image and when you click the button it links to index.html and on the index.html I have 1 image. I want to make it so every time I click a button it puts me to the index.html page and the corresponding image on products.html gets put on the index.html image

<div class="imgbx">
    <button onclick="window.location.href='index.html'" >Invisible button</button>
    <img src="images/xr-black.jpg" alt="">
</div>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Inside products.html add

<div class="imgbx">
    <button onclick="window.location.href='index.html?image=images/xr-black.jpg'" >Invisible button</button>
    <img src="images/xr-black.jpg" alt="">
</div>

In your main.html add

<img src="img" id="image">
<script>
    const queryString = window.location.search;
    const urlParams = new URLSearchParams(queryString);
    const image = urlParams.get('image')
    document.getElementById('image').src = image;

</script>
about 4 years ago · Juan Pablo Isaza Relatório
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