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

155
Vistas
Dynamic image on page where img src changes based on parameter in url

I was wondering if it was possible to change an image source on a page based on a url parameter? Perhaps using Javascript?

For example, if we have the default image with an ID?

The scenario would be, http://example.com/page-name/?image-id=specifiedimg

and this would load the image as what the source is set for "specifiedimg"

Hoping that makes sense?

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You can specify the image path in the url and then use URLSearchParams to get the image path and then set the image as source to the image element.

for example: http://example.com/page-name.html?image-id=assets/img/something.png

const searchParams = new URLSearchParams(location.search),
  imagePath = searchParams.get('image-id'),
  image = new Image() // you can use querySelector to target an existing image tag
image.src = imagePath;

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