Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

161
Views
Imagen dinámica en la página donde img src cambia según el parámetro en la URL

Me preguntaba si era posible cambiar una fuente de imagen en una página en función de un parámetro de URL. ¿Quizás usando Javascript?

Por ejemplo, si tenemos la imagen por defecto con un ID?

El escenario sería, http://example.com/page-name/?image-id=specifiedimg

y esto cargaría la imagen como la fuente está configurada para "specifiedimg"

¿Esperando que eso tenga sentido?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Puede especificar la ruta de la imagen en la URL y luego usar URLSearchParams para obtener la ruta de la imagen y luego establecer la imagen como fuente para el elemento de la imagen.

por ejemplo: 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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!