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

203
Vistas
Change <img> source after window.location.replace

When I press a button on my main page, it retrieves a link to an image using an api. Then I want to redirect to another page of mine and change the src attribute to the link i fetched with the api (on the new page).

Everything works besides the change image source.

Main page button:

<button onclick="search()" class="submit-button">SEARCH</button>

Java Script (Edit: JavaScript is stored in separate file 'script.js')

function search() {
    const username = document.getElementById("username").value

    // API CALL HERE WHICH CALLS presentImg()

}

function presentImage(url) {
    console.log(url)
    window.location.replace("profile.html")

    document.getElementById("image").src = url;

}

Profile.html

<img id="image" src="#">

When I open the main page and click the button I am redirected and the profile.html page opens but the image is not displayed. I have already checked the url, it works and shows only one image. I also tried to load a local image in my project folder, that doesn't work either.

about 4 years ago · Juan Pablo Isaza
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