473,411 Members | 1,937 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,411 software developers and data experts.

Swap images if Javascript is disabled

Hello out there,
I know that I can replace an image with another using e.g.
onMouseOver="swapIn(...)"
and
onMouseOut="swapOut(...)"

Is there anything I can do if Javascript is disabled?
- I guess I could use 'noscript' to provide a link which opens an
external window to display the second image'
- any other possibilty?

On a related note: Is it possible (without Javascript) to open a new
window giving its dimension and omitting the usual "decorations" - it
is for displaying a small image which looks ridiculous if a "normal"
window would open.
Any info will be greatly appreciated.
Best regards
Helmut Giese
Jun 27 '06 #1
7 2652
hg****@ratiosoft.com (Helmut Giese) wrote:
Hello out there,
I know that I can replace an image with another using e.g.
onMouseOver="swapIn(...)"
and
onMouseOut="swapOut(...)"

Is there anything I can do if Javascript is disabled?
If it's a background images then you can change it via :hover in CSS.
- I guess I could use 'noscript' to provide a link which opens an
external window to display the second image'
- any other possibilty?
Just link to it normnally as the standard, then add JavaScript on top
of that. Starting with the JS gizmos and then adding the basics is
almost always the wrong way round.
On a related note: Is it possible (without Javascript) to open a new
window giving its dimension and omitting the usual "decorations"
No.
it is for displaying a small image which looks ridiculous if a "normal"
window would open.


Then don't open it in a new window. Leave it up to the user to decide
how to display the image.

Steve
--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net> <http://steve.pugh.net/>
Jun 27 '06 #2
Helmut Giese wrote:
Hello out there,
I know that I can replace an image with another using e.g.
onMouseOver="swapIn(...)"
and
onMouseOut="swapOut(...)"

Is there anything I can do if Javascript is disabled?

- I guess I could use 'noscript' to provide a link which opens an
external window to display the second image'


What's the purpose of the rollover when JS is enabled? Is it just a
presentational enhancement or is the rollover image really meaningful
content? If it's just presentational, it doesn't matter if it's not
shown to some users and it's certainly not worth linking to separately.

--
Lachlan Hunt
http://lachy.id.au/
http://GetFirefox.com/ Rediscover the Web
http://GetThunderbird.com/ Reclaim your Inbox
Jun 28 '06 #3
On Tue, 27 Jun 2006 22:09:55 +0100, Steve Pugh <st***@pugh.net> wrote:

Hi Steve,
I know that I can replace an image with another using e.g.
onMouseOver="swapIn(...)"
and
onMouseOut="swapOut(...)"

Is there anything I can do if Javascript is disabled?


If it's a background images then you can change it via :hover in CSS.

No, it's part of the presentation. Hm, could a table have a background
image which would then change via :hover in CSS? Probably not.
- I guess I could use 'noscript' to provide a link which opens an
external window to display the second image'
- any other possibilty?


Just link to it normnally as the standard, then add JavaScript on top
of that. Starting with the JS gizmos and then adding the basics is
almost always the wrong way round.

Well, the assumption here is that Javascript is disabled.
On a related note: Is it possible (without Javascript) to open a new
window giving its dimension and omitting the usual "decorations"

No.

Too bad.
it is for displaying a small image which looks ridiculous if a "normal"
window would open.


Then don't open it in a new window. Leave it up to the user to decide
how to display the image.

It's a relatively small window (350 x 350) being part of a rather
large page. Displaying the second image in the same window would
completely lose the context, while showing it in a separate (smaller)
window would retain it.
But, well, if the technology doesn't allow it, then so be it.
Thanks for the info and best regards
Helmut Giese
Jun 28 '06 #4
On Wed, 28 Jun 2006 11:54:46 +1000, Lachlan Hunt
<sp***********@gmail.com> wrote:

Hi Lachlan,
What's the purpose of the rollover when JS is enabled? Is it just a
presentational enhancement or is the rollover image really meaningful
content? If it's just presentational, it doesn't matter if it's not
shown to some users and it's certainly not worth linking to separately.

No, it's the central part of the message. Something like
This is how things are now.
Move the mouse over the image to see
how it could be like. :)
So I would like to find a way to present it in a meaningful way even
if Javascript is disabled.
Best regards
Helmut Giese
Jun 28 '06 #5
Helmut Giese wrote:
On Tue, 27 Jun 2006 22:09:55 +0100, Steve Pugh <st***@pugh.net> wrote:

Hi Steve,
I know that I can replace an image with another using e.g.
onMouseOver="swapIn(...)"
and
onMouseOut="swapOut(...)"

Is there anything I can do if Javascript is disabled?
If it's a background images then you can change it via :hover in CSS.>


No, it's part of the presentation.


But in your reply to Lachlan you said "No, it's the central part of the
message." Which is it? Presentation or content? If its content then
keep it in the HTML and don't make it a background image.

Based on what you say there "This is how things are now.
Move the mouse over the image to see
how it could be like. :)"
I would suggest putting both images in the page as normal content and
letting the user see them side by side rather than only having one
visible at a time. Especially for users without a mouse...
Hm, could a table have a background
image which would then change via :hover in CSS? Probably not.


Of course.

Shame about IE which only supports :hover on links.
- I guess I could use 'noscript' to provide a link which opens an
external window to display the second image'
- any other possibilty?


Just link to it normally as the standard, then add JavaScript on top
of that. Starting with the JS gizmos and then adding the basics is
almost always the wrong way round.


Well, the assumption here is that Javascript is disabled.


If that's the assumption then don't use JavaScript at all.

My advice was based on the assumption that some people would have
JavaScript and some people wouldn't.
it is for displaying a small image which looks ridiculous if a "normal"
window would open.


Then don't open it in a new window. Leave it up to the user to decide
how to display the image.


It's a relatively small window (350 x 350) being part of a rather
large page. Displaying the second image in the same window would
completely lose the context, while showing it in a separate (smaller)
window would retain it.


One click to close popup.
One click to go back to previous page.

No difference in getting back to the "context".

Steve

Jun 28 '06 #6
Helmut Giese wrote:
On Wed, 28 Jun 2006 11:54:46 +1000, Lachlan Hunt
<sp***********@gmail.com> wrote:
What's the purpose of the rollover when JS is enabled? Is it just a
presentational enhancement or is the rollover image really meaningful
content? If it's just presentational, it doesn't matter if it's not
shown to some users and it's certainly not worth linking to separately.


No, it's the central part of the message. Something like
This is how things are now.
Move the mouse over the image to see
how it could be like. :)
So I would like to find a way to present it in a meaningful way even
if Javascript is disabled.
Best regards
Helmut Giese


You could try something like this:

<a href="more-info" class="before-after">
<img src="before.jpg" class="before" alt="...">
<img src="after.jpg" class="after" alt="...">
</a>

a.before-after img.after { position: absolute; left: -2000px; }

a.before-after:hover img.before,
a.before-after:focus img.before { position: absolute; left: -2000px; }

a.before-after:hover img.after,
a.before-after:focus img.after { position: static; }

You could use display: none; instead of positioning them off screen, but
then, unfortunately, broken screen readers wouldn't read the alt text.

That way, no javascript is required at all. It should work in IE and
users with CSS disabled still get both images.

--
Lachlan Hunt
http://lachy.id.au/
http://GetFirefox.com/ Rediscover the Web
http://GetThunderbird.com/ Reclaim your Inbox
Jun 28 '06 #7
Hi Steve and Lachlan,
I want to thank you both for your suggestions, but more urgent things
have come up :(
Actually I am a software developer helping out on the HTML front line,
but currently one of my programs gives us or rather a customer some
headaches, so I have to concentrate on this issue.
I'll be back as soon as this will be resolved.
Best regards
Helmut Giese
Jun 29 '06 #8

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

Similar topics

3
by: Randell D. | last post by:
Folks, I'm still learning javascript - I've invested in a couple of books and reading online as much as possible. I'm pretty sure what I am suggesting is possible though I'm trying to weigh up...
2
by: Frank Bishop | last post by:
I have been trying to do image swaps and my second image does not show up, it just goes to a blank image on the mouseover. I have Windows XP SP2 and it prompts me to allow blocked content when the...
4
by: bridgemanusa | last post by:
Hi All: I have a very long page of html that I want to take portions and hide them in divs, then show when a link is clicked. I have the hide show part working when the link is clicked, however...
12
by: LAshooter | last post by:
I have a portfolio page which loads a dozen thumbnails and one large image. A friend helped me code a script (below) which will swap out the large image (named "imgLarg") when a different thumbnail...
6
by: Karl | last post by:
Hi, Ok so on a given page I have 4 text links: see it in black see it in blue see it in red see it in green using the standard swap image behavior, clicking on one of the above links
5
by: Ed Jay | last post by:
Why doesn't the following swap images? <head> <javascript type="text/javascript"> function swapImage() {document.images.image1.src=/images/1stimage.gif;} function swapBack()...
3
by: steve.peticca | last post by:
Hi, My onmousevent fails to switch the large photo with one of the smaller images. To be frank, I'm extremely new to Javascript programming and as such, am trying to learn from other sites...
3
by: PEJO | last post by:
I'm not much of a JS programmer so I used the the standard Macromedia swap image function for a disjointed rollover..which works fine.. no problem swapping the image with that code.... but when...
5
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
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
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,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...
0
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...

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.