473,568 Members | 2,964 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.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
Jul 23 '05 #1
1 1699
Christophe Candas wrote:
<snip>
function position(e) { <snip> document.getEle mentById('zoom' ).style.backgro und="url <snip> }

if (navigator.appN ame.substring(0 ,3) == "Net")
document.captur eEvents(Event.M OUSEMOVE);
document.onmous emove = position;

</SCRIPT> <snip> <BODY BGCOLOR="#FFFFF F"> <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.getEle mentById('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
2802
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 and above. The progress bar code is written in javascript in an external js file (progressbar.js). The web screen is in a seperate jsp file...
4
3824
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 beautiful script "http://javascript.internet.com/navigation/toolbar-menu.html". It works like a charm. I made my webpage in frames, where the...
8
2543
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 an alternative to pop-up windows in a web page. The code I have works (sort of). The problem is that I can move these layers around when I move the...
2
9797
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 anyone tell me whether or not C# allow to do this? pei_world
4
3111
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. This is a link to a very simple page that contains 2 DIV statements: http://xsinx.no-ip.com:8880/TestEmbedDiv.html One of them is embeded in the...
3
1675
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 rolls over text within a paragraph (without breaking the text up). my knowledge is pretty basic, but, by looking at other websites, i have been...
2
4560
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 divs on IE and no problem, but on firefox if I do the same, some divs just got hidden without notice. try clicking variably on different divs and it...
7
1799
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 image (1 out of 3 images will be randomly chosen by the javascript code) <script language=JavaScript> images = new Array(3); images = "<img...
0
7693
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7604
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7916
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8117
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6275
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5498
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
2101
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.