/    Sign up×
Community /Pin to ProfileBookmark

onMouseOver without anchor

I need an onMouseOver image flip function that does not require the anchor tag. Will anyone help?

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@swonDec 18.2002 — It gives many different scripts, an easy script is the next, but it will not works in browser < 5 and I've not tried it in Opera:

<html><head><title>Test</title>

<script type="text/javascript">

<!--

function imageflip(nr)

{

obj = "flip"+nr;

var newimg = new Array("test.jpg","nextnewimage.jpg");

var newalt = new Array("New Image0 Alt","New Image1 Alt");

elm = document.getElementById(obj).setAttribute("src",newimg[nr]);

elm = document.getElementById(obj).setAttribute("alt",newalt[nr]);

}

function imageflipback(or)

{

obj = "flip"+or;

var oldimg = new Array("yourimage.jpg","nextoldimage.jpg");

var oldalt = new Array("Old Image0 Alt","Old Image1 Alt");

elm = document.getElementById(obj).setAttribute("src",oldimg[or]);

elm = document.getElementById(obj).setAttribute("alt",oldalt[or]);

}

//-->

</script>

</head><body>

<img src="yourimage.jpg" id="flip0" width="100" height="50" border="0" alt="Old Image0 Alt" onMouseover="imageflip('0')" onMouseout="imageflipback('0')">

<img src="yourimage.jpg" id="flip1" width="100" height="50" border="0" alt="Old Image1 Alt" onMouseover="imageflip('1')" onMouseout="imageflipback('1')">

</body>

</html>
Copy linkTweet thisAlerts:
@Beach_BumDec 18.2002 — a mouseover does not require an anchor in the first place. this works in both IE and NS.

<img src="1.gif"

onmouseover="document.header.src='2.gif'"

onmouseout="document.header.src='1.gif'"

width="65" height="65" name="header" alt="">
Copy linkTweet thisAlerts:
@gil_davisDec 19.2002 — [b]this works in both IE and NS.[/b][/quote]
You should provide specific version information. What you posted will not work in NS <= 4 or IE <= 3.
×

Success!

Help @genghiscon_net spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...