What happened to the old image rollover script?
It was not restored, because the editors cannot trace a CodeLifter rollover page in the surviving link records, and the effect no longer needs a script. Two images and a CSS :hover rule do the swap. Add :focus-visible so keyboard users see the same change, and keep anything important out of the hover state.
Cite
CodeLifter Forum, "What happened to the old image rollover script?", https://forum.codelifter.com/posts/what-happened-to-the-old-image-rollover-script/, accessed 2026-10-16.- CodeLifter editorsStaffStaff, CodeLifter ·
What the records show
The Script Shelf lists every old script the editors can tie to a name and an address: fifteen of them, taken from links to the original site that still exist and from its redirect map, checked on 2026-10-15. An image rollover is not among them. That list is not the full original catalogue, so a rollover page may well have existed. If you have a working link to one on the old site, post it in this thread so the shelf can be checked against it.
What the shelf does show is where the old scripts went. Six became reviewed prompts, five were replaced by something built into the browser, and four were retired. A rollover would fall in the second group.
What a rollover script did
The common pattern of that era was a pair of images and two event handlers: on
mouseover, change thesrcof the image to the highlighted version; onmouseout, change it back. Scripts usually preloaded the second image so the swap did not flash. It worked with a mouse and nothing else: no keyboard focus, no touch, and nothing for a screen reader beyond the first image's alt text.Can you keep an old rollover that still works?
Probably, in the narrow sense:
mouseoverandmouseoutstill fire for a mouse, and swapping an imagesrcis ordinary DOM code. The problems are the ones it always had. Keyboard users never see the highlighted state, touch users may get it stuck, and inlineonmouseover="..."attributes are hard to audit next to the rest of your markup. If the rollover is on a link people need to find, replace it with the CSS version below. If it is pure decoration on a page nobody maintains, it can wait until you next edit the file.The CSS version
Put both images inside the link and let CSS decide which one shows:
<a class="swap" href="/catalogue/"> <img src="catalogue.png" alt="Catalogue" width="200" height="120"> <img class="swap-on" src="catalogue-on.png" alt="" width="200" height="120"> </a>.swap { position: relative; display: inline-block; } .swap-on { position: absolute; inset: 0; opacity: 0; } @media (hover: hover) { .swap:hover .swap-on { opacity: 1; } } .swap:focus-visible .swap-on { opacity: 1; } @media (prefers-reduced-motion: no-preference) { .swap-on { transition: opacity 150ms; } }Why each part is there:
- The second image has
alt="". MDN's img reference says an empty alt marks an image as not a key part of the content, so non-visual browsers may skip it. The link's name comes from the first image only. :hoversits inside@media (hover: hover). MDN's :hover page warns that on touchscreens the pseudo-class "might never match, match only for a moment after touching an element, or continue to match" until another element is touched. The hover media feature tests whether the primary input can hover conveniently, so phones skip the effect instead of getting stuck in it.:focus-visiblegives the same change when someone tabs to the link. MDN describes it as matching when the element has focus and the browser decides focus should be made evident.- The fade runs only when the visitor has not asked the system to reduce motion, using
prefers-reduced-motion.
Both images download with the page, so there is nothing to preload.
Old and new side by side
Script rollover CSS rollover Trigger mouseoverandmouseouthandlers:hoverand:focus-visibleKeyboard No change on focus Same change on focus Touch Often stuck in one state Effect skipped where hover is not convenient Works with JavaScript off No Yes Code to maintain Handlers per image, preload list One rule set for every .swaplinkIf you ask an assistant for one
Ask for the behaviour, not "a rollover script", or you may get the 1999 pattern back with
onmouseoverattributes. Lines worth putting in the prompt:- "Use CSS only:
:hoverinside@media (hover: hover), plus:focus-visible. No JavaScript." - "The second image is decorative:
alt=""." - "Do not put any text or link that only appears on hover."
- "Wrap any transition in
prefers-reduced-motion: no-preference."
How to write a coding prompt explains why naming the failure modes works better than naming the effect. The keyboard prompting thread covers the same idea for scripts that do need JavaScript, and if you still have an old rollover pasted into a page, the thread on whether old cut-and-paste scripts still work explains what to check before you leave it there.
- The second image has
Write something first.
Give people something to work with: at least 30 words on what happened and what you tried.
That is too long. Keep it under 6,000 characters.
Write the question as the title, 15 to 140 characters, no links.
Pick a category.
Add a name (2 to 40 characters, no links).
That email address does not look right.
That was quick. Read the thread, then try again.
The form expired. Reload the page and post again.
Something went wrong with the form. Reload and try again.
Please complete the check and post again.
Limit reached for now. Try again later.
This thread is closed to new replies.
This thread no longer accepts replies.
Something went wrong with the form. Reload and try again.
Post a reply or question first (name and email), then this browser can vote, edit and accept answers.
You cannot vote on your own post.
Only the author (within 30 days) or the forum team can do that.
That email belongs to a forum team account. Use your sign-in link instead.
New accounts are paused for the moment. Try again later.
That was already posted.