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

136
Vistas
How to onclick, innerHTML to a new page

here is my script but for now it innerHTML to the same page. I wrap my movie card in a tag, to redirect to the second page, but i'm unable to figure out how make this excute the fuunction displayMovieInfo() in the target page. i've been trying to figure it out and make researches for 3 days now, with no success. i would appreciate your help ( im learning JS )

getMovies(API_URL)

async function getMovies(url) {
    const res = await fetch(url);
    const data = await res.json();

    console.log(data);

    displayMovies(data.results);
}

function displayMovies(movies) {
    moviesWrapper.innerHTML = '';
    // movies.forEach((movie) => {
    movies.slice(-4).forEach((movie) => {
        const { title, poster_path, vote_average, overview } = movie;
        const movieElement = document.createElement('div');
        movieElement.classList.add('movie-card');

        movieElement.innerHTML = `
        <a href="film.html"><img src="${IMAGE_PATH + poster_path}" alt="${title}"/>
        <div class='movie-content'>
        
        <div class='desc'>
        <h2>${title}</h2>
        ${vote_average}
        </div>
        </div>
        </a>
        `
        moviesWrapper.appendChild(movieElement);


        movieElement.onclick = function displayMovieInfo() {


            const movieInfo = document.getElementById('about');

            // movieInfoContainer.classList.add('about');
            movieInfo.innerHTML = `
            <h2 class="about-title">${title}</h2>
            <hr>
                <div class='about-content'>
                <img class="about-img" src="${IMAGE_PATH + poster_path}" alt="${title}"/>
                <div class='description'>
                <p>${overview}<p>
                </div>
                </div>
                `
                // movieInfo.appendChild(movieSpec);

            movieInfo.scrollIntoView(true);
        };
    });
};
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