Hye,
You will find here under a script which will load a picture in a layer ,
picture depending on the cursor position. Everything's ok until the line:
document.getEle mentById('zoom' ).style.backgro und="url('chemi n
image.gif')";
which doesn't work.
The script works (indication in the status barre) but the image is not
loaded in the layer...
I'm quiet sure it's a problem of url syntaxe but I can't find it ???
<script language="JavaS cript" type="text/JavaScript">
nom_precedent = "/images/panorama_1.gif" ;
function position(e) {
x = (navigator.appN ame.substring(0 ,3) == "Net") ? e.pageX :
event.x+documen t.body.scrollLe ft;
y = (navigator.appN ame.substring(0 ,3) == "Net") ? e.pageY :
event.y+documen t.body.scrollTo p;
posx = Math.ceil(x/1014*21);
posy = Math.ceil(y/290*12)-1;
if (posx<=1) posx=1;
if (posx>=21) posx=21;
if (posy<=0) posy=0;
if (posy>=7) posy=11;
num = posx+(posy*21);
nom = "../../../../_images/_trainers_05012 4/images/panorama_"+num+ ".gif";
if (nom != nom_precedent) {
window.status = "Souris posx:"+posx+" | posy:"+posy+" | numéro:"+num+" |
image:"+nom;
// Netscape
if (document.getEl ementById){
document.getEle mentById('zoom' ).style.backgro und="url('../../../../_images/_trainers_05012 4/images/panorama_51.gif ')";
}
if (document.all && !document.getEl ementById){
document.all['zoom'].style.backgrou nd="url('../../../../_images/_trainers_05012 4/images/panorama_51.gif ')";
}
// IE
if (document.layer s) {
document.layers['zoom'].style.backgrou nd="url('../../../../_images/_trainers_05012 4/images/panorama_51.gif ')";
}
nom_precedent = nom;
}
}
if (navigator.appN ame.substring(0 ,3) == "Net")
document.captur eEvents(Event.M OUSEMOVE);
document.onmous emove = position;
</SCRIPT>
</HEAD>
<!--C.Candas, 2004.-->
<BODY BGCOLOR="#FFFFF F">
<img src="../../../../_images/_trainers_05012 4/panorama_flat.j pg"
width="1014" height="290" border="0">
<p align="center" class="retrait" >Glissez la souris sur la zone de l'image
que vous souhaitez agrandir ci dessous.</p>
<div id="zoom" style="position :absolute; width:500px; height:250px;
z-index:1; visibility: visible; left: 257px; top: 346px; background-image:
url(../../../../_images/_trainers_05012 4/images/panorama_54.gif );
layer-background-image:
url(../../../../_images/_trainers_05012 4/images/panorama_54.gif ); border:
1px none #000000;"></div>
Thanks in advance for your help.
Christophe
You will find here under a script which will load a picture in a layer ,
picture depending on the cursor position. Everything's ok until the line:
document.getEle mentById('zoom' ).style.backgro und="url('chemi n
image.gif')";
which doesn't work.
The script works (indication in the status barre) but the image is not
loaded in the layer...
I'm quiet sure it's a problem of url syntaxe but I can't find it ???
<script language="JavaS cript" type="text/JavaScript">
nom_precedent = "/images/panorama_1.gif" ;
function position(e) {
x = (navigator.appN ame.substring(0 ,3) == "Net") ? e.pageX :
event.x+documen t.body.scrollLe ft;
y = (navigator.appN ame.substring(0 ,3) == "Net") ? e.pageY :
event.y+documen t.body.scrollTo p;
posx = Math.ceil(x/1014*21);
posy = Math.ceil(y/290*12)-1;
if (posx<=1) posx=1;
if (posx>=21) posx=21;
if (posy<=0) posy=0;
if (posy>=7) posy=11;
num = posx+(posy*21);
nom = "../../../../_images/_trainers_05012 4/images/panorama_"+num+ ".gif";
if (nom != nom_precedent) {
window.status = "Souris posx:"+posx+" | posy:"+posy+" | numéro:"+num+" |
image:"+nom;
// Netscape
if (document.getEl ementById){
document.getEle mentById('zoom' ).style.backgro und="url('../../../../_images/_trainers_05012 4/images/panorama_51.gif ')";
}
if (document.all && !document.getEl ementById){
document.all['zoom'].style.backgrou nd="url('../../../../_images/_trainers_05012 4/images/panorama_51.gif ')";
}
// IE
if (document.layer s) {
document.layers['zoom'].style.backgrou nd="url('../../../../_images/_trainers_05012 4/images/panorama_51.gif ')";
}
nom_precedent = nom;
}
}
if (navigator.appN ame.substring(0 ,3) == "Net")
document.captur eEvents(Event.M OUSEMOVE);
document.onmous emove = position;
</SCRIPT>
</HEAD>
<!--C.Candas, 2004.-->
<BODY BGCOLOR="#FFFFF F">
<img src="../../../../_images/_trainers_05012 4/panorama_flat.j pg"
width="1014" height="290" border="0">
<p align="center" class="retrait" >Glissez la souris sur la zone de l'image
que vous souhaitez agrandir ci dessous.</p>
<div id="zoom" style="position :absolute; width:500px; height:250px;
z-index:1; visibility: visible; left: 257px; top: 346px; background-image:
url(../../../../_images/_trainers_05012 4/images/panorama_54.gif );
layer-background-image:
url(../../../../_images/_trainers_05012 4/images/panorama_54.gif ); border:
1px none #000000;"></div>
Thanks in advance for your help.
Christophe
Comment