• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

134
Views
JS Necesita ayuda para agregar href en img

Estoy usando Innova Content Builder para registrar mi página web. Contiene un módulo llamado saveimage.php que transforma imágenes binarias en archivos jpg. Esto funciona perfectamente.

Ahora, me gustaría encapsular estos img con enlaces href, pero no funciona.

Aquí está mi código:

 parent.document.getElementById('img-" . $count . "').setAttribute('src','" . $urlpath . $image . "'); parent.document.getElementById('img-" . $count . "').setAttribute('alt','".$image."'); var myLink = document.createElement('a'); myLink.setAttribute('href','http://www.google.fr'); parent.document.getElementById('img-" . $count . "').appendChild(myLink);

Este código se coloca en una función de carga del cuerpo. Creo que es un problema de paternidad.

Me puedes ayudar ? Gracias !

about 3 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Utilizar este:

 <script> parent.document.getElementById('img-" . $count . "').setAttribute('src','" . $urlpath . $image . "'); parent.document.getElementById('img-" . $count . "').setAttribute('alt','".$image."'); var myLink = document.createElement('a'); myLink.setAttribute('href','http://www.google.fr'); parent.document.getElementById('img-" . $count . "').parentNode.insertBefore(myLink, parent.document.getElementById('img-" . $count . "')); myLink.appendChild(parent.document.getElementById('img-" . $count . "')); </script>
about 3 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error