473,651 Members | 3,029 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with some browsers when changing a displayed image

I have a small image on my web page that, when clicked, does some
javascript stuff which changes the page. To highlight that this has
happened, I want to replace the image with another. Each is a 16x16
pixel image.

The images are pre-loaded:

var image_g = new Image (16, 16);
var image_r = new Image (16, 16);
image_g.src = 'pics/arrow-g.jpg';
image_r.src = 'pics/arrow-r.jpg';
Then later when the user clicks on the image, I do (e.g.) this:

document.getEle mentById('pixie ').src = image_g.src;

where pixie is an <imgin an <a hrefin a table cell.

This works fine in Safari, IE (Mac and XP), Netscape 7 (XP), and FireFox
2.0.0.1 (Mac). However it does not work in Netscape 6 (XP) and FireFox
2.0 (XP). The behaviour is as if the statement were commented out - I
get no Javascript errors, but the statement is ignored.

Am I somehow missing something which would make this completely standard
JS? Any clues appreciated.

Thanks,

-- tim
Jan 22 '07 #1
4 1375
Tim Streater wrote:
I have a small image on my web page that, when clicked, does some
javascript stuff which changes the page. To highlight that this has
happened, I want to replace the image with another. Each is a 16x16
pixel image.

The images are pre-loaded:

var image_g = new Image (16, 16);
var image_r = new Image (16, 16);
image_g.src = 'pics/arrow-g.jpg';
image_r.src = 'pics/arrow-r.jpg';
Then later when the user clicks on the image, I do (e.g.) this:

document.getEle mentById('pixie ').src = image_g.src;
Why not the following?
document.getEle mentById('pixie ').src = 'pics/arrow-g.jpg';

or

document.images['pixie'].src = 'pics/arrow-g.jpg';
// provided you have named your image space.

Mick
>
where pixie is an <imgin an <a hrefin a table cell.

This works fine in Safari, IE (Mac and XP), Netscape 7 (XP), and FireFox
2.0.0.1 (Mac). However it does not work in Netscape 6 (XP) and FireFox
2.0 (XP). The behaviour is as if the statement were commented out - I
get no Javascript errors, but the statement is ignored.

Am I somehow missing something which would make this completely standard
JS? Any clues appreciated.

Thanks,

-- tim
Jan 22 '07 #2
In article <45************ ***********@roa drunner.com>,
Michael White <mi**@mickweb.c omwrote:
Tim Streater wrote:
I have a small image on my web page that, when clicked, does some
javascript stuff which changes the page. To highlight that this has
happened, I want to replace the image with another. Each is a 16x16
pixel image.

The images are pre-loaded:

var image_g = new Image (16, 16);
var image_r = new Image (16, 16);
image_g.src = 'pics/arrow-g.jpg';
image_r.src = 'pics/arrow-r.jpg';
Then later when the user clicks on the image, I do (e.g.) this:

document.getEle mentById('pixie ').src = image_g.src;

Why not the following?
document.getEle mentById('pixie ').src = 'pics/arrow-g.jpg';
That doesn't actually work either. According to Danny Goodman's JS
Bible, I should do what I am doing - in particular since sometimes I
want to assign it to image_r.src.

Today I discover that this *does* work in FireFox 1.5.0.9 under XP, but
not 2 or 2.0.0.1 under XP. So I'll downgrade on the XP machine for the
moment (if I can find it :-) to 1.5.0.9.
or

document.images['pixie'].src = 'pics/arrow-g.jpg';
// provided you have named your image space.
Nor familiar with this so I'll check in it. Thanks.

-- tim
Jan 23 '07 #3
In article <45************ ***********@roa drunner.com>,
Michael White <mi**@mickweb.c omwrote:
Tim Streater wrote:
I have a small image on my web page that, when clicked, does some
javascript stuff which changes the page. To highlight that this has
happened, I want to replace the image with another. Each is a 16x16
pixel image.

The images are pre-loaded:

var image_g = new Image (16, 16);
var image_r = new Image (16, 16);
image_g.src = 'pics/arrow-g.jpg';
image_r.src = 'pics/arrow-r.jpg';
Then later when the user clicks on the image, I do (e.g.) this:

document.getEle mentById('pixie ').src = image_g.src;

Why not the following?
document.getEle mentById('pixie ').src = 'pics/arrow-g.jpg';

or

document.images['pixie'].src = 'pics/arrow-g.jpg';
// provided you have named your image space.
Nope. behaves identically.

-- tim
Jan 23 '07 #4
VK

Tim Streater wrote:
I have a small image on my web page that, when clicked, does some
javascript stuff which changes the page. To highlight that this has
happened, I want to replace the image with another. Each is a 16x16
pixel image.

The images are pre-loaded:

var image_g = new Image (16, 16);
var image_r = new Image (16, 16);
image_g.src = 'pics/arrow-g.jpg';
image_r.src = 'pics/arrow-r.jpg';
That is the key question I say _if_ they are preloaded. Image object
was added in Netscape 3.0 to better support newly introduced roll-over
effect: namely to avoid loading delays when passing for the _first
time_ over some roll-over image. On the second and any feature pass it
was irrelevant if you pre-loaded image or not: in either case it would
go w/o delay from the browser cache (I'm talking about conventional
images sent with no tricky response headers).
This way
var img = new Image();
img.src = 'path/to/image';
would mean "enforce loading and caching this image file"

This techniques was later adopted by IE 4 and others - but no one
AFAICT ever promised that forcing to cache something in such way will
work forever. So possibly on recent UAs Image functionality was
considered as not matching modern security and annoyance protection -
if it is indeed so then I could name at least several reasons. So
possibly extra cache-related functionality from Image object was
removed and now it is as abstract as:
var img = {
"src" : "path/to/image"
}

I am not using graphics roll-overs since about 2003, so I can say
nothing for sure. Some testing to check it out would be great.

Jan 23 '07 #5

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

Similar topics

32
2501
by: Werner Partner | last post by:
Hier is the problem: http://asterix/sonoptikon.de/artemis/index.php The <h1> and <h2> make their ellbows so broad that in the picture arise borders on top and bottom. The general question is: How can I force left frame and banner to be exactly as broad resp. as high as the picture?
6
2251
by: Robert Lapes | last post by:
I'm just getting into using CSS and I'm having a problem getting Opera to display a Navigation Bar in the same way as IE6. Can someone please point me in the right direction? The site I'm working on can be seen at http://www.budbury.co.uk/itel/index.htm In Opera 6.05 the Nav Bar image floats behind the content division that follows the navbar.
4
2422
by: VR | last post by:
First, greetings to everyone :) I'm doing a university seminar & I've encountered a problem. I have a gallery with thumbnails linked on pictures. What I want is popup to be opened with dimensions of linked picture after clicking on a thumbnail. I found javascript which is compatible with IE, Firefox & Opera but I can't get it to work. All I get is this http://www.justfonts.com/tini/problem.html (thumbnail dissapeared).
4
3714
by: Saso Zagoranski | last post by:
Hi! Here is what I'm trying to do: I have created a UserControl named PictureView. It holds all the images in one directory in the Bitmap images variable. The selected image is displayed in the PictureBox control. Here is how it works.
3
1299
by: Larry | last post by:
I've set up a list of image filesnames in a listview control(lvSrcFileList), I'm using the selectedIndexChange event to select which file is being displayed in a picturebox control(pbImagePreview). The first time a filename is selected it works fine but if I try to select another filename the program bombs with an exception error; flagging the line below "curntImage = Image.FromFile(cpath). The listview is set for a single selection....
7
2094
by: Andrew Christiansen | last post by:
Hey everyone. I have Visual Basic .NET 2003 and am trying to show images on a treeview control. I have the imagelist on the form filled with images, and have the ImageList property of the treeview control set to the imagelist containing the images I want to be displayed next to each node. It seems that no matter what I do there will be no images displayed next to the nodes during runtime. I tried creating nodes during designtime using...
3
2293
by: Mark Szlazak | last post by:
The following page simulates a pool cue and cue ball: http://members.aol.com/myscript/cue.html Mouse cursor position around the cue ball determines where a roll-over of 179 pool cue images is placed around the ball and which one of those images is displayed. Each pool cue image is in a slightly different orientation and the correct one is chosen to match the orientation of the cursor around the ball. Holding down the left mouse button...
23
5917
by: Peter | last post by:
I have a problem with a page show_image.asp that returns a jpg image under Windows XP Pro SP2. The page sets content type as: Response.ContentType = "image/jpg" While this works perfectly fine on most machines, on some machines I experience this problem: When loading the page a window pops up that asks if I want to open the document show_page.asp. When I click "Open" Interdev pops up and opens up a
4
1519
by: STIAdmin | last post by:
Happy Holidays to all of you! This is my first time posting. I'm working on a web project and trying to get this done before Christmas. The limitation is that I'm using an out of the box program and I don't have the skills to change it quickly, and it only outputs in a structured way... so I am not able to go dig into the code of the out-of-box program and solve it. This it the first time I've really dug into JS. My JS knowledge is very...
0
8357
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8277
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8803
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8700
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7298
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6158
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5612
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4285
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2701
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

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.