473,386 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Problem to load the background in a layer

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.getElementById('zoom').style.background=" url('chemin
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="JavaScript" type="text/JavaScript">
nom_precedent = "/images/panorama_1.gif";

function position(e) {
x = (navigator.appName.substring(0,3) == "Net") ? e.pageX :
event.x+document.body.scrollLeft;
y = (navigator.appName.substring(0,3) == "Net") ? e.pageY :
event.y+document.body.scrollTop;

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_050124/images/panorama_"+num+".gif";

if (nom != nom_precedent) {

window.status = "Souris posx:"+posx+" | posy:"+posy+" | numéro:"+num+" |
image:"+nom;

// Netscape
if (document.getElementById){
document.getElementById('zoom').style.background=" url('../../../../_images/_trainers_050124/images/panorama_51.gif')";
}

if (document.all && !document.getElementById){
document.all['zoom'].style.background="url('../../../../_images/_trainers_050124/images/panorama_51.gif')";
}

// IE
if (document.layers) {
document.layers['zoom'].style.background="url('../../../../_images/_trainers_050124/images/panorama_51.gif')";
}

nom_precedent = nom;
}
}

if (navigator.appName.substring(0,3) == "Net")
document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = position;

</SCRIPT>

</HEAD>
<!--C.Candas, 2004.-->

<BODY BGCOLOR="#FFFFFF">
<img src="../../../../_images/_trainers_050124/panorama_flat.jpg"
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_050124/images/panorama_54.gif);
layer-background-image:
url(../../../../_images/_trainers_050124/images/panorama_54.gif); border:
1px none #000000;"></div>

Thanks in advance for your help.
Christophe
Jul 23 '05 #1
1 1687
Christophe Candas wrote:
<snip>
function position(e) { <snip> document.getElementById('zoom').style.background=" url <snip> }

if (navigator.appName.substring(0,3) == "Net")
document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = position;

</SCRIPT> <snip> <BODY BGCOLOR="#FFFFFF"> <snip> <div id="zoom" style="position:absolute; width:500px; ...

<snip>

Because you assign the - position - function as a mosemove handler
inline, before the page body (and particularly the <DIV ID="zoom">
element) has been parsed by the browser, if there is a mosemove event in
the interval between the assignment of the handler and the creation of
the DIV element in the DOM then the - document.getElementById('zoom') -
method call will return - null -, and the rest of that expression will
result in an exception being thrown.

Richard.
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Lizzy | last post by:
I have an internet application which has a progress bar show whenever the customer is requesting data from the server. This progress bar is coded to work in both Netscape 4.75 and above and IE 5.0...
4
by: JesusFreak | last post by:
From: us_traveller@yahoo.com (JesusFreak) Newsgroups: microsoft.public.scripting.jscript Subject: toolbar script problem NNTP-Posting-Host: 192.92.126.136 Recently, I downloaded the following...
8
by: rdlebreton | last post by:
Hi, Folks! I've been trying to develop my own version of these draggable layers and I have been limiting myself to IE6...for now. I have looked at some other examples to get ideas of creating...
2
by: pei_world | last post by:
Hi I want to create a image with multiple layers on top. the background color of each layer should be transparent except the last one, hence I can only see the drawed items on such layers. can...
4
by: zz | last post by:
Sorry for posting this here but unfortunatly I couldn't find any appropriate newsgroup for this and since I've been active here with .net question I figured you guys might be able to help. ...
3
by: reproots | last post by:
hi there, i am having trouble with a span command and would like to know if someone can help me, or point me in the correct direction. basically, i want a little textbox to pop up when a mouse...
2
by: reynoldlariza | last post by:
Can somebody please help me, i tried playing around with IE6 and Firefox 2.0 browser for setting zIndexes and hide & show of divs. It seems to work to both. I tried repeatedly clicking on different...
7
crystal2005
by: crystal2005 | last post by:
Hi all, I'm currenty creating a website. I got one confusing problem related to CSS and JavaScript actually, not really html. The problem is, I actually want my welcome screen page is to be random...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.