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 !
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>