Foros del Web » Programando para Internet » Javascript »

Problema con onmouseover

Estas en el tema de Problema con onmouseover en el foro de Javascript en Foros del Web. Wenas gente, Vereis tengo un script que en cuanto paso por enciama de un link, en un DIV me aparece una fotografia. Esto es justo ...
  #1 (permalink)  
Antiguo 09/10/2007, 03:56
 
Fecha de Ingreso: diciembre-2005
Ubicación: BCN
Mensajes: 165
Antigüedad: 18 años, 4 meses
Puntos: 2
Problema con onmouseover

Wenas gente,

Vereis tengo un script que en cuanto paso por enciama de un link, en un DIV me aparece una fotografia. Esto es justo lo que yo queria hacer pero tiene un problema. Cuando pulso el link no hace ninguna acción, tengo que pulsar la imagen que se ha creado al pasar por encima para que me vaya a la pagina indicada. Vereis, este es el codigo:

Código HTML:
<div align="left"><a href="imganes/galeria_flash/campo/click.jpg" rel="enlargeimage::mouseover" rev="loadarea::javascript:popup('imganes/galeria_flash/campo/index.html')">- Camp de futbol</a><a href="javascript:popup('imganes/galeria_flash/campo/index.html')"></a> </div> 
Y este es el DIV que me muestra la imagen cada vez que paso por encima:

Código HTML:
<div id="loadarea" style="width: 400px"></div> 
Pues bien, quiero que al pasar por encima me aparezca la imagen pero el link o hipervinculo este el en texto y no en la imagen.

Porcierto, aclaro que las palabras "enlargeimage::" y "loadarea::" corresponden a un script en .js que es el que hace que todo funcione.

Nada mas, muchas gracias

Saludos
  #2 (permalink)  
Antiguo 09/10/2007, 07:16
Avatar de messer  
Fecha de Ingreso: julio-2004
Mensajes: 467
Antigüedad: 19 años, 9 meses
Puntos: 5
Re: Problema con onmouseover

Creo que lo mejor es que publiques el codigo, no es sencillo imaginar lo que estas haciendo alli. Sin embargo puedo ver que teneis un link vacio, <a href="pagina.html"></a>,con que objeto??

Saludos!
__________________
<script type="text/messerScript"><!--
window.onload=function(){ loadMesserRules(this.href) }
--></script>
  #3 (permalink)  
Antiguo 09/10/2007, 11:10
 
Fecha de Ingreso: diciembre-2005
Ubicación: BCN
Mensajes: 165
Antigüedad: 18 años, 4 meses
Puntos: 2
Re: Problema con onmouseover

Haver, he rescatado el script entero, aqui lo teneis:
El Script esta sacado de DynamicDrive.com
Aunque haya usado las etiquetas de PHP, es un codigo javascript para que veais mas claro con colores y todo eso ;).


Código PHP:
// -------------------------------------------------------------------
// Image Thumbnail Viewer II- By Dynamic Drive, available at: http://www.dynamicdrive.com
// Last updated: Feb 5th, 2007
// -------------------------------------------------------------------

var thumbnailviewer2={
enableTitletrue//Should "title" attribute of link be used as description?
enableTransitiontrue//Enable fading transition in IE?
hideimgmouseoutfalse//Hide enlarged image when mouse moves out of anchor link? (if enlarged image is hyperlinked, always set to false!)

/////////////No need to edit beyond here/////////////////////////

iefilterstring'progid:DXImageTransform.Microsoft.GradientWipe(GradientSize=1.0 Duration=0.7)'//IE specific multimedia filter string
iefiltercapabledocument.compatMode && window.createPopuptrue false//Detect browser support for IE filters
preloadedimages:[], //array to preload enlarged images (ones set to display "onmouseover"
targetlinks:[], //array to hold participating links (those with rel="enlargeimage:initType")
alreadyrunflagfalse//flag to indicate whether init() function has been run already come window.onload

loadimage:function(linkobj){
var 
imagepath=linkobj.getAttribute("href"//Get URL to enlarged image
var showcontainer=document.getElementById(linkobj.getAttribute("rev").split("::")[0]) //Reference container on page to show enlarged image in
var dest=linkobj.getAttribute("rev").split("::")[1//Get URL enlarged image should be linked to, if any
var description=(thumbnailviewer2.enableTitle && linkobj.getAttribute("title"))? linkobj.getAttribute("title") : "" //Get title attr
var imageHTML='<img src="'+imagepath+'" style="border-width: 0" />' //Construct HTML for enlarged image
if (typeof dest!="undefined"//Hyperlink the enlarged image?
imageHTML='<a href="'+dest+'">'+imageHTML+'</a>'
if (description!=""//Use title attr of the link as description?
imageHTML+='<br />'+description
if (this.iefiltercapable){ //Is this an IE browser that supports filters?
showcontainer.style.filter=this.iefilterstring
showcontainer
.filters[0].Apply()
}
showcontainer.innerHTML=imageHTML
this
.featureImage=showcontainer.getElementsByTagName("img")[0//Reference enlarged image itself
this.featureImage.onload=function(){ //When enlarged image has completely loaded
if (thumbnailviewer2.iefiltercapable//Is this an IE browser that supports filters?
showcontainer.filters[0].Play()
}
this.featureImage.onerror=function(){ //If an error has occurred while loading the image to show
if (thumbnailviewer2.iefiltercapable//Is this an IE browser that supports filters?
showcontainer.filters[0].Stop()
}
},

hideimage:function(linkobj){
var 
showcontainer=document.getElementById(linkobj.getAttribute("rev").split("::")[0]) //Reference container on page to show enlarged image in
showcontainer.innerHTML=""
},


cleanup:function(){ //Clean up routine on page unload
if (this.featureImage){this.featureImage.onload=nullthis.featureImage.onerror=nullthis.featureImage=null}
this.showcontainer=null
for (var i=0i<this.targetlinks.lengthi++){
this.targetlinks[i].onclick=null
this
.targetlinks[i].onmouseover=null
this
.targetlinks[i].onmouseout=null
}
},

addEvent:function(targetfunctionreftasktype){ //assign a function to execute to an event handler (ie: onunload)
var tasktype=(window.addEventListener)? tasktype "on"+tasktype
if (target.addEventListener)
target.addEventListener(tasktypefunctionreffalse)
else if (
target.attachEvent)
target.attachEvent(tasktypefunctionref)
},

init:function(){ //Initialize thumbnail viewer script
this.iefiltercapable=(this.iefiltercapable && this.enableTransition//True or false: IE filters supported and is enabled by user
var pagelinks=document.getElementsByTagName("a")
for (var 
i=0i<pagelinks.lengthi++){ //BEGIN FOR LOOP
if (pagelinks[i].getAttribute("rel") && /enlargeimage:/i.test(pagelinks[i].getAttribute("rel"))){ //Begin if statement: Test for rel="enlargeimage"
var initType=pagelinks[i].getAttribute("rel").split("::")[1//Get display type of enlarged image ("click" or "mouseover")
if (initType=="mouseover"){ //If type is "mouseover", preload the enlarged image for quicker display
this.preloadedimages[this.preloadedimages.length]=new Image()
this.preloadedimages[this.preloadedimages.length-1].src=pagelinks[i].href
pagelinks
[i]["onclick"]=function(){ //Cancel default click action
return false
}
}
pagelinks[i]["on"+initType]=function(){ //Load enlarged image based on the specified display type (event)
thumbnailviewer2.loadimage(this//Load image
return false
}
if (
this.hideimgmouseout)
pagelinks[i]["onmouseout"]=function(){
thumbnailviewer2.hideimage(this)
}
this.targetlinks[this.targetlinks.length]=pagelinks[i//store reference to target link
//end if statement
//END FOR LOOP


//END init() function

}


if (
document.addEventListener//Take advantage of "DOMContentLoaded" event in select Mozilla/ Opera browsers for faster init
thumbnailviewer2.addEvent(document, function(){thumbnailviewer2.alreadyrunflag=1thumbnailviewer2.init()}, "DOMContentLoaded"//Initialize script on page load
else if (document.all && document.getElementsByTagName("a").length>0){ //Take advantage of "defer" attr inside SCRIPT tag in IE for instant init
thumbnailviewer2.alreadyrunflag=1
thumbnailviewer2
.init()
}
thumbnailviewer2.addEvent(window, function(){if (!thumbnailviewer2.alreadyrunflagthumbnailviewer2.init()}, "load"//Default init method: window.onload
thumbnailviewer2.addEvent(window, function(){thumbnailviewer2.cleanup()}, "unload"
Por esta parte el script.
Ahora os pongo la parte del BODY en la que se muestra la imagen al pasar por encima de un link el raton:

Código HTML:
<a href="imagenes/foto1.jpg"
 rel="enlargeimage::mouseover" 
rev="loadarea::http://www.dynamicdrive.com" 
title="This is an example">Thumbnail Example 1</a> 
Y ahora el codigo del DIV donde se muestra la imagen:

Código HTML:
<div id="loadarea" style="width: 600px"></div> 
Y bien, esta es toda la parte del script. Ahora os cuento. Tenemos un hipervinculo, en el cual al pasar el raton por encima, se muestra una imagen en el DIV, pero si hacemos click en el link no secede nada, sino k hemos de pulsar la imagen para que nos lleve al vinculo.

Yo quiero que en vez de pulsar en la imagen, pulsando en el link se me lleve al vinculo pero que no modifique nada del script, es decir, que al pasar por encima el raton se muestre la imagen en el DIV pero que al clikar se me lleve al vinculo indicado.

Muchas gracias, y espero haberme expresado correctamente.

Saludos,
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 07:03.