/    Sign up×
Community /Pin to ProfileBookmark

Image rollover and call function

Is it possible to have an image rollover link and have a function called the onmouseover event at the same time. I ask this as I am trying to get this code to work:

function about()
{
document.about.src = “images/about_over.gif”;
loadProgram(“includes/xml_programs/about.xml”);
}

<a href=”http://localhost/OGIO/includes/about.php” onmouseover=”javascript: about();” onmouseout=”document.about.src=’images/about_over.gif'”><img src=”images/about.gif” border=”0″></a>

Cheers anyone

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@FangMay 21.2008 — &lt;img [COLOR="Green"]name="about"[/COLOR] src="images/about.gif" border="0"&gt;
Copy linkTweet thisAlerts:
@John73216authorMay 21.2008 — Oops, I did actually use that but it still caused a problem i.e:

Error: document.about has no properties

So I tried this with an id also and used getelementbyid but still no luck.

Cheers for reply
Copy linkTweet thisAlerts:
@FangMay 21.2008 — Change the name of the function or the image; they should not be the same.
Copy linkTweet thisAlerts:
@ChazzlMay 21.2008 — Move your [I]onmouseout[/I] event into the image element and use [I]this[/I] to reference itself. No need for a name attribute.

[code=html]<html>
<head>
<title>Image rollover and call function</title>
<script type="text/javascript">
function about(objImg){
objImg.src = "images/about_over.gif";
loadProgram("includes/xml_programs/about.xml");
}
</script>
</head>
<body>
<a href="http://localhost/OGIO/includes/about.php">
<img src="images/about.gif" border="0" onmouseover="about(this);" onmouseout="this.src='images/about_over.gif';" />
</a>
</body>
</html>
[/code]
Copy linkTweet thisAlerts:
@John73216authorMay 21.2008 — Cheers - that solved it.
×

Success!

Help @John73216 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.16,
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,
)...