By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,759 Members | 1,778 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,759 IT Pros & Developers. It's quick & easy.

Swapping images causes blanks....

P: n/a
I know this is sorta reposting but I want to simplify the issue a bit. Take
the following script:

function replacemain(s){
var x = document.images['MainImage'];
var y = document.images[s];
var pictemp = x.src;
x.src = y.src;
y.src = pictemp;
}

All I want to do is replace the image specified as "s" with the MainImage.
Actually swap them so that each execution of the function will swapp and
reswap the images without loosing anything. This generally works, however,
on a couple IE6 browsers it causes blank images to swap in.

Visit
http://callandermats.adconn.com/cata...d=23&subcat=14

To see what I mean. It may not go blank for you but trust me, it does for
others. Any ideas why this might happen?

Jon
Jul 23 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Jon Glazer wrote:
<snip>
... . This generally works, however, on a
couple IE6 browsers it causes blank
images to swap in.

<snip>

You are describing one of the many know negative side-effects of the use
of the javascript pseudo-protocol in HREFs, and you are using
javascript: pseudo-protocols in the HREFs of the links that trigger the
function (and others).

Richard.
Jul 23 '05 #2

P: n/a
Ahh.. ok an intelligent response ;-)

Can you suggest an alternative method to achieve the same results?

Thanks!!
Jon

"Richard Cornford" <Ri*****@litotes.demon.co.uk> wrote in message
news:cs*******************@news.demon.co.uk...
Jon Glazer wrote:
<snip>
... . This generally works, however, on a
couple IE6 browsers it causes blank
images to swap in.

<snip>

You are describing one of the many know negative side-effects of the use
of the javascript pseudo-protocol in HREFs, and you are using
javascript: pseudo-protocols in the HREFs of the links that trigger the
function (and others).

Richard.

Jul 23 '05 #3

P: n/a
Jon Glazer wrote:
Ahh.. ok an intelligent response ;-)

Can you suggest an alternative method to achieve the same results?

Replace the href "link" with an onclick, as in the HTML
source posted in response to your question yesterday.

e.g.:

<a href="javascript:void replacemain('b')"><img
alt="Waterhog™&nbsp;&nbsp;Classic" ID="Image_b"
width=80 border=0 src="catalogimg/items/23-b.jpg"></a>

Changes to:

<img
alt="Waterhog™&nbsp;&nbsp;Classic" ID="Image_b"
width=80 border=0 src="catalogimg/items/23-b.jpg"
onclick="replacemain('b');"


Note: remove the <a ...></a> tags completely.
--
Rob
Jul 23 '05 #4

P: n/a
RobG wrote:
<snip>
<img
alt="WaterhogT&nbsp;&nbsp;Classic" ID="Image_b"
width=80 border=0 src="catalogimg/items/23-b.jpg"
onclick="replacemain('b');"
>


Note: remove the <a ...></a> tags completely.


Among the many things that deserve some consideration in script design
is accessibility (in the WAI sense). An onclick handler on an IMG tag is
a very pointing device oriented piece of code (at least without a mass
of other code to reproduce what the browser could have done itself). At
least an IMG wrapped in a link can be navigated to with the keyboard,
and usually also activated with it.

But no code examples here as top-posting OPs don't warrant that.

Richard.
Jul 23 '05 #5

P: n/a
Richard Cornford wrote:
[...]
Among the many things that deserve some consideration in script design
is accessibility (in the WAI sense). An onclick handler on an IMG tag is
a very pointing device oriented piece of code (at least without a mass
of other code to reproduce what the browser could have done itself). At
least an IMG wrapped in a link can be navigated to with the keyboard,
and usually also activated with it.
A good point, for the sake of a bit of UI design discussion...

Consider if JavaScript is disabled. The image will appear to be a link
(cursor changes on hover), but if clicked on nothing will happen.
Similarly if the user has images turned off.

Also, although the image looks like a link, it just modifies the
current page, it doesn't actually load anything or go anywhere.

I would try to include in the site design visual cues on what is
going to happen when the image is clicked on. For example:

The alt text could be "Show a sample" and the current alt tag (which
seems to be the name of the carpet sample) moved to a title attribute

On-screen help text could be added just above the sample thumbnails
saying "Click to see a larger sample".

These may seem trivial points, but all should be considered in the
overall page design.
But no code examples here as top-posting OPs don't warrant that.


Hope the OP doesn't just top-read... :-)

--
Rob
Jul 23 '05 #6

P: n/a
RobG wrote:
Richard Cornford wrote: <snip>
... . At least an IMG wrapped in a link can be navigated
to with the keyboard, and usually also activated with it.


A good point, for the sake of a bit of UI design discussion...

Consider if JavaScript is disabled. The image will appear to
be a link (cursor changes on hover), but if clicked on nothing
will happen. Similarly if the user has images turned off.

Also, although the image looks like a link, it just modifies the
current page, it doesn't actually load anything or go anywhere.


Given a properly coded onclick handler on the A element the question
arises as to what should appear in the HREF attribute. The answer may be
the URL of the larger image that was to be swapped in (or the URL of a
static HTML page that would frame the image, or a server-side script
that would do the same, but also be potentially useable with other
images).

Thus you have a link that really is a link, and a design that will also
work (at least to the point of being fully functional) in the absence of
client-side scripting. It also provides the user with the additional
option of opening the larger image in another tab/window if they feel
they want to. And so javascript provides an enhancement to the
functionality of the page, when available, but the design degrades
cleanly to a functional system in its absence. The ability to operate
via the keyboard is a bonus.
I would try to include in the site design visual cues on what
is going to happen when the image is clicked on. For example:

The alt text could be "Show a sample" and the current alt tag
(which seems to be the name of the carpet sample) moved to a
title attribute
We could have a debate about what would constitute the 'correct' use of
ALT and TITLE under these circumstances, but they do need some thought
in this context.
On-screen help text could be added just above the sample
thumbnails saying "Click to see a larger sample".
"Click to ..." is pointing device oriented terminology that is
discouraged in accessibility circles (and others), but written
instructions usually have considerable value.
These may seem trivial points, but all should be considered
in the overall page design.

<snip>

In practice script design is as much of an issue (more of an issue
really) as error free, working execution. It deserves discussion,
probably more than it gets.

Richard.
Jul 23 '05 #7

P: n/a
Richard Cornford wrote:
[...]
"Click to ..." is pointing device oriented terminology...
Not to me.
... that is
discouraged in accessibility circles (and others)...


Those who think that way have allowed political correctness to cloud
their logic.

Presumably the user, having navigated to the site, has an interface
that allows them to cause clicks to happen in web pages. Asking them
to click on an image implies only that they should cause a click event
to occur over the image.

Exactly how the user makes that happen is up to them. Presumably they
have chosen an interface that suits their circumstance - voice
activated, thought-controlled, servo-assisted or even a mouse.

I guess "Tell your slave to click here" is right out - I shouldn't
presume the user has the ability to speak or their slave to hear. ;-)

P.S. I must confess that I still say "tidal wave" from time to time
even though I learned what a tsunami is in primary school.

--
Rob
Jul 23 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.