C
Aquí les dejo la versión actualizada del script que agrega un enlace cuando te copian, lo modifiqué para generar anclas de manera aleatoria (AMIGABLE A PENGUIN) y le arreglé un GRAVÍSIMO problema con un div.
Funciona en explorer, chrome, firefox y safari. No funciona en Opera.
Ver el archivo adjunto 12705
Agregar el oncopy en la etiqueta body:
Insertar CODE, HTML o PHP:<body oncopy="return addLink()">
Peguen este script antes de la etiqueta </html>
Cambiar mi.DOMINIO.com y DOMINIO.com
Insertar CODE, HTML o PHP:<script type="text/javascript"> //Cambiar mi.DOMINIO.com var Ancla = ["mi.DOMINIO.com", "DOMINIO.com", document.location.href, document.title]; var Texto = ["Fuente:", "Leer completo:"]; var AnclaRandom = Ancla[Math.floor(Math.random() * Ancla.length)]; var TextoRandom = Texto[Math.floor(Math.random() * Texto.length)]; function addLink() { var body_element = document.getElementsByTagName('body')[0]; var selection; selection = window.getSelection(); var pagelink = "<br /><br />"+TextoRandom+" <a href='"+document.location.href+"' href='"+document.title+"'>"+AnclaRandom+"</a>"; var copytext = selection + pagelink; var newdiv = document.createElement('p'); body_element.appendChild(newdiv); newdiv.innerHTML = copytext; selection.selectAllChildren(newdiv); window.setTimeout(function() { body_element.removeChild(newdiv); },0); } </script>
Dejen sus comentarios.
en cualquier lugar de body va la primera
y el mi.dominio.com (es con www.111111.com) y el otro es sin la www?
a mi también me da ese error bloggerBuenas,
Cuando pego el código del Script en blogger me dá el siguiente error:
Error al analizar XML, línea 1011, columna 109: Attribute "href" was already specified for element "a".
Si miro la línea en cuestión, es ésta:
var pagelink = "<br /><br />"+TextoRandom+" <a href='"+document.location.href+"' href='"+document.title+"'>"+AnclaRandom+"</a>";
alguna idea?
Gracias.
Buenas,
Cuando pego el código del Script en blogger me dá el siguiente error:
Error al analizar XML, línea 1011, columna 109: Attribute "href" was already specified for element "a".
Si miro la línea en cuestión, es ésta:
var pagelink = "<br /><br />"+TextoRandom+" <a href='"+document.location.href+"' href='"+document.title+"'>"+AnclaRandom+"</a>";
alguna idea?
Gracias.
Aquí les dejo la versión actualizada del script que agrega un enlace cuando te copian, lo modifiqué para generar anclas de manera aleatoria (AMIGABLE A PENGUIN) y le arreglé un GRAVÍSIMO problema con un div.
Funciona en explorer, chrome, firefox y safari. No funciona en Opera.
Ver el archivo adjunto 12705
Agregar el oncopy en la etiqueta body:
Insertar CODE, HTML o PHP:<body oncopy="return addLink()">
Peguen este script antes de la etiqueta </html>
Cambiar mi.DOMINIO.com y DOMINIO.com
Insertar CODE, HTML o PHP:<script type="text/javascript"> //Cambiar mi.DOMINIO.com var Ancla = ["mi.DOMINIO.com", "DOMINIO.com", document.location.href, document.title]; var Texto = ["Fuente:", "Leer completo:"]; var AnclaRandom = Ancla[Math.floor(Math.random() * Ancla.length)]; var TextoRandom = Texto[Math.floor(Math.random() * Texto.length)]; function addLink() { var body_element = document.getElementsByTagName('body')[0]; var selection; selection = window.getSelection(); var pagelink = "<br /><br />"+TextoRandom+" <a href='"+document.location.href+"' [B]href='"+document.title+"'[/B]>"+AnclaRandom+"</a>"; var copytext = selection + pagelink; var newdiv = document.createElement('p'); body_element.appendChild(newdiv); newdiv.innerHTML = copytext; selection.selectAllChildren(newdiv); window.setTimeout(function() { body_element.removeChild(newdiv); },0); } </script>
Dejen sus comentarios.
Para todos los que tenéis este error, sólo tenéis que eliminar lo que he puesto en negrita en la cita. Es decir, esto:
href='"+document.title+"'
De hecho esa línea no sirve de nada. Ya la borré. Gracias.
Excelente código. Hace tiempo lo venía buscando y lo implementé desde que salió este post. 🙂
sirve para wordpress tambien?, que archivo hay que tocar?
Utilizamos cookies y tecnologías similares para los siguientes fines:
¿Aceptas las cookies y estas tecnologías?
Utilizamos cookies y tecnologías similares para los siguientes fines:
¿Aceptas las cookies y estas tecnologías?