Quesito da dilettante
Ho "condensato" due codici scaricati da HTML.it,
uno mi apre le thumbnail in una immagine fluttuante nella stessa pagina,
l'altro mi permette di ridimensionare a piacere l'immagine se ho monitor con risoluzioni differenti.
Il problema è che i tasti per ridimensionare l'immagine funzionano solo se stanno al di fuori del <div> fluttuante! Se provo a metterli accanto al tasto "Chiudi" non funzionano più!
Dove sta il problema?
Qua sotto la pagina di esempio:
codice:
<html xmlns="http://www.w3.org/1999/xhtml" lang="it">
<head>
<script type="text/javascript" language="JavaScript">
<!--
var ie=document.all
var ns=document.layers
var ns6=document.getElementById&&!document.all
function enlarge(which,e){
crossobj=document.getElementById? document.getElementById("showimage") : document.all.showimage
if (crossobj.style.visibility=="hidden"){
crossobj.style.left=ns6? pageXOffset+e.clientX : document.body.scrollLeft+event.clientX
crossobj.style.top=ns6? pageYOffset+e.clientY : document.body.scrollTop+event.clientY
crossobj.innerHTML='<div align=left> <SPAN STYLE="cursor: hand"> <img src=http://gtu.altervista.org/chiudi.jpg onClick=closepreview()>   </span>   ...e vorrei metterli qua dentro
<SPAN STYLE="cursor: move"> [img]'+which+'[/img]</span></div>'
crossobj.style.visibility="visible"
}
else
crossobj.style.visibility="hidden"
return false
}
function fixImg(whId, maxW) {
var pix=document.getElementById(whId);
pix.width=maxW*pix.width/10;
}
function closepreview(){
crossobj.style.visibility="hidden"
}
var nsx,nsy,nstemp
function drag_dropns(name){
temp=eval(name)
temp.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP)
temp.onmousedown=gons
temp.onmousemove=dragns
temp.onmouseup=stopns
}
function gons(e){
temp.captureEvents(Event.MOUSEMOVE)
nsx=e.x
nsy=e.y
}
function dragns(e){
temp.moveBy(e.x-nsx,e.y-nsy)
return false
}
function stopns(){
temp.releaseEvents(Event.MOUSEMOVE)
}
function drag_drop(e){
if (ie&&dragapproved){
crossobj.style.left=tempx+event.clientX-offsetx
crossobj.style.top=tempy+event.clientY-offsety
}
else if (ns6&&dragapproved){
crossobj.style.left=tempx+e.clientX-offsetx
crossobj.style.top=tempy+e.clientY-offsety
}
return false
}
function initializedrag(e){
if (ie&&event.srcElement.id=="drag"||ns6&&e.target.id=="drag"){
offsetx=ie? event.clientX : e.clientX
offsety=ie? event.clientY : e.clientY
tempx=parseInt(crossobj.style.left)
tempy=parseInt(crossobj.style.top)
dragapproved=true
document.onmousemove=drag_drop
}
}
document.onmousedown=initializedrag
document.onmouseup=new Function("dragapproved=false")
//-->
</script>
</head>
<body text=#ffff00 vLink=#990099 aLink=#0000ff link=#0000ff bgColor=#000000>
<div align="center">
<div id="showimage" style="position:absolute;visibility:hidden;border:1px dashed #666666"> </div>
<TABLE align=left> <TBODY>
<TR> <TD align=middle>Questi sono i bottoni per ridimensionare la foto</TD></TR>
<TR> <TD align=middle> <img src=http://gtu.altervista.org/piu.jpg onClick=fixImg('drag',15)>   <img src=http://gtu.altervista.org/meno.jpg onClick=fixImg('drag',5)>  
<TABLE> <TBODY>
<TR>
<TD><SPAN STYLE="cursor: hand" onClick="return enlarge('http://gtu.altervista.org/2007/Dream45.jpg',event)">
</span></TD>
<TD><SPAN STYLE="cursor: hand" onClick="return enlarge('http://gtu.altervista.org/2007/Dream38.jpg',event)">
</span></TD>
<TD><SPAN STYLE="cursor: hand" onClick="return enlarge('http://gtu.altervista.org/2007/Dream36.jpg',event)">
</span></TD>
</TD></TR></TBODY></TABLE>
</TD></TR></TBODY></TABLE>
</div>
</body>
</html>
Grazie per i consigli.
Greg