Problems with image preload

J

JB

Hi everybody.

I've a strange problem with preload of images.

I've an html page that's showing a cinema's venue. I build the page
dynamically with a <script></script> section included in <body>


Something like this.
.....
for (var i=0; i< arrID.length-1;i++) {
var st = parseInt(arrSt);
var src;
var clickEvent;
var extraStyle;
if (st == 2) {
src="img/poltrona_rossa.gif";
events = "";
extraStyle= "";
} else {
src="img/poltrona_verde.gif";
events = 'onclick="seleziona(this);" onmouseover="highlight(this,true);"
onmouseout="highlight(this,false)"';
extraStyle="cursor:hand;cursor:pointer;";
}
document.writeln('<img src="'+src+'" id="'+ arrID +'" title="'+
arrID + '" status="'+st+'" style="position:absolute;visibility:hidden;'+
extraStyle+'" '+events+'>');
}

I've added this code in <head> section to preload the images that identifies
all 3 possible status (free, sold, selected)

var ptV = new Image();
ptV.src = "img/poltrona_verde.gif";
var ptG = new Image();
ptG.src = "img/poltrona_gialla.gif";
var ptR = new Image();
ptR.src = "img/poltrona_rossa.gif";

and the highlight function that is called whe mouse enter/exit on an image
is like this:

function highlight(obj,mode) {
if (mode) {
if (obj.getAttribute("status") == "0") obj.src =
"img/poltrona_gialla.gif";
} else {
if (obj.getAttribute("status") == "0") {
obj.src = "img/poltrona_verde.gif";
}
}
}

All is working well but when the mouse pass over an image, I can see the
hourglass to appear while loading the "selected" image (switching between
the normal image and the selected image and vice-versa)

I thought that since i've preloaded all the images, this "reloading"
shouldn't happen...what's wrong??

Any help would be very appreciated...
JB
 
R

rf


Works fine here. All images preloaded (IE and Mozilla).

No network activity at all on mouseover. Are your settings correct in your
browser?

BTW that is a very complicated way of doing this. You could use a little
tiny bit of CSS to do the whole thing and it would work when javascript is
disabled as well. I would hate do maintain this page. In fact I wouldn't :)
 
J

JB

Works fine here. All images preloaded (IE and Mozilla).
No network activity at all on mouseover. Are your settings correct in your
browser?

This problem only happen on IE on my pc. Which settings should I take care
of?
BTW that is a very complicated way of doing this. You could use a little
tiny bit of CSS to do the whole thing and it would work when javascript is
disabled as well. I would hate do maintain this page. In fact I wouldn't :)

This page is part of a cinema's reservation system and is a jsp. It reads
the location of every seat from a XML rappresentation of the cinema's venue
and fills the arrays with this data ().

This way all the processing is done on client side.
How would you use CSS to obtain this? I could use CSS to switch image on
mouseover/mouseout but I need to make other operations during this events
(show seat details, such as price and others) so javascript is still needed.

Any advice is welcome!
Thanks for your help
JB
 
R

rf

JB said:
This problem only happen on IE on my pc. Which settings should I take care
of?

Have a look at your cache settings.
This page is part of a cinema's reservation system and is a jsp. It reads
the location of every seat from a XML rappresentation of the cinema's venue
and fills the arrays with this data ().

Ah, intranet, you should state this right up front. The default here is web.
This way all the processing is done on client side.
How would you use CSS to obtain this? I could use CSS to switch image on
mouseover/mouseout but I need to make other operations during this events
(show seat details, such as price and others) so javascript is still
needed.

Each seat looks like a link. Normal web (ie client server) would result in a
trip back to the server for each link hit. Then CSS could be used to change
the background of each link (a:hover etc). If you want some sort of client
side process to also happen on mouseover then javascript is required, but
you could make it a *lot* simpler.
 
J

Jeff Thies

This way all the processing is done on client side.
How would you use CSS to obtain this? I could use CSS to switch image on
mouseover/mouseout but I need to make other operations during this events
(show seat details, such as price and others) so javascript is still needed.

There's little point in having every seat absolutely positioned.

You can simply count the number of seats and throw in a <br> for the
next row. You can still retrieve the image's position if you need it.

Jeff
 
M

Marix

rf said:
BTW that is a very complicated way of doing this. You could use a little
tiny bit of CSS to do the whole thing and it would work when javascript is
disabled as well. I would hate do maintain this page. In fact I wouldn't :)

You mean that css can hover images?

Could you provide some code sample, please?

Menus with rollovers would be nice without java!

;)
 
J

JB

My actual system generate a <table venueRows x venueCols > and fill it with
images...but with very large venue (>800 seats) the server must generate a
very large page for every request...so I was investigating the possibility
to get some results using more client-side power and this solutions seem to
meet my target. I could create it dinamically and still use the table method
but this method seems to work as well and I can obtain pixel perfect
rappresentation of the venue...

I cannot use CSS to control onmouseover/onmouseout events just because if a
seat is selected, when you pass over it and then exit from it it should
mantain its selected icon.

Thanks a lot for your help. I will make some other trials with this code...
JB
 
M

Matrix

Mark Parnell wrote:

Mark Parnell wrote:

You do your menus in Java? I pity your visitors.


What's wrong with java scripts?

I'm working on that site, trying to clear html soup and make it more
functional.

http://www.touchofeternity.com/news_css_menu.htm

For a look I prefer java menu.

I know some browsers do not support java, so some do not support css.

Any suggestion how to improve that page would be a warm welcome.


Except colours and feel. ;-D


The boss likes it that way.


Thanks Mark.
 
R

rf

Matrix said:
Mark Parnell wrote:
What's wrong with java scripts?

Mark was pointing out, tongue in cheek, that Java has no relationship at all
to Javascript, except three common letters in the names and a vague C++
feel.

And it is Javascript, not java scripts.
I'm working on that site, trying to clear html soup and make it more
functional.

No you are not. You are making it less functional. Rumour has it that 15% of
viewers do not/can not use javascript. Every viewer you have supports HTML.

Oower, I can see why you want to simplify your HTML. However, that is the
point. Simplify the HTML. Don't complicate it with Javascript band-aids
For a look I prefer java menu.

Java or javascript? You are doing it again :)
I know some browsers do not support java, so some do not support css.

Javascript (I am assuming you mean) may be used to add embelishments to a
site. Relying on it for such fundemtal things as navigation is folly. Hint:
google does not understand javascript and will not index your site.

CSS is for optional presentational support. It is not required to access the
content. Google ignores it.
Any suggestion how to improve that page would be a warm welcome.

Google around for your competitors. Look at their sites. Note good things
that they do that you do not. Show your boss these things.

I find the site rather tedious to use, colour notwithstanding. It's so, er,
vertical :)
 
K

Karl Groves

Matrix said:
Mark Parnell wrote:

Mark Parnell wrote:




What's wrong with java scripts?

I'm working on that site, trying to clear html soup and make it more
functional.

http://www.touchofeternity.com/news_css_menu.htm

For a look I prefer java menu.

I know some browsers do not support java, so some do not support css.

Any suggestion how to improve that page would be a warm welcome.

Perhaps the biggest help would be for you to understand that Java and
JavaScript are two entirely different things.

-Karl
 
M

Matrix

rf said:
Mark was pointing out, tongue in cheek, that Java has no relationship at all
to Javascript, except three common letters in the names and a vague C++
feel.

And it is Javascript, not java scripts.




No you are not. You are making it less functional. Rumour has it that 15% of
viewers do not/can not use javascript. Every viewer you have supports HTML.




Oower, I can see why you want to simplify your HTML. However, that is the
point. Simplify the HTML. Don't complicate it with Javascript band-aids



Java or javascript? You are doing it again :)




Javascript (I am assuming you mean) may be used to add embelishments to a
site. Relying on it for such fundemtal things as navigation is folly. Hint:
google does not understand javascript and will not index your site.

CSS is for optional presentational support. It is not required to access the
content. Google ignores it.




Google around for your competitors. Look at their sites. Note good things
that they do that you do not. Show your boss these things.

I find the site rather tedious to use, colour notwithstanding. It's so, er,
vertical :)


Hmmm... I wonder, why these javascript rollovers are working on IE and
Firefox without java in browser installed?

I'm new in this (not expert, God forbid!) but I love to understand
something.

I mean without MSJAVX86.EXE installed for IE and Sun' Java package in
Firefox.

Applets are not working if these are not present, but scripts are
working perfectly.


Any hints?
 
P

PeterMcC

Matrix wrote in
Hmmm... I wonder, why these javascript rollovers are working on IE and
Firefox without java in browser installed?

I'm new in this (not expert, God forbid!) but I love to understand
something.

I mean without MSJAVX86.EXE installed for IE and Sun' Java package in
Firefox.

Applets are not working if these are not present, but scripts are
working perfectly.

Because Java and JavaScript are different things - as may have been
mentioned earlier. Turning off Java doesn't affect JavaScript.
 
R

rf

Matrix said:
Hmmm... I wonder, why these javascript rollovers are working on IE and
Firefox without java in browser installed?

Sigh... <beats head against wall/>

Once again are you talking about java or javascript? You use both words in
the above sentence. The two languages, once again, have absolutely no
relationship to each other. Nothing at all in common. It's like talking
about a car (an automobile) and a carpet (a floor coverings). Get it?
Any hints?

Get your teminology correct. Until then there is no point in continuing this
thread.

BTW Please learn to trim and quote correctly.
 
M

Matrix

rf said:
Matrix wrote:




Sigh... <beats head against wall/>

Once again are you talking about java or javascript? You use both words in
the above sentence. The two languages, once again, have absolutely no
relationship to each other. Nothing at all in common. It's like talking
about a car (an automobile) and a carpet (a floor coverings). Get it?





I just have realized that javascript and java are two different things.

So I have made a progress. Did I mentioned that I'm new to this?

I'm sure I did.

Did you figured out what I meant at all?

Never mind...


Get your teminology correct. Until then there is no point in continuing this
thread.


Great!

You have been so kind.

Thank you very much.
 
M

Matrix

Karl Groves wrote:

Perhaps the biggest help would be for you to understand that Java and
JavaScript are two entirely different things.

-Karl



Thanks. I think I have more to learn.

All I wanted to know is rollovers with images, done in css and I thought
that java or javascript is the same thing.

Than I was told that menu in javascript is a bad idea.

I've supplied link to a page and my mistake was calling javascript a
'java'.

However, on web page was clear what I have used and what I meant.

But... I'm a wog and I was many time badly treated, this time included.


Not by you Karl!


Thanks again...


Cheers...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top